Skip to content
StackPractices

file handling

Practical resources about file handling for software engineers.

31 results

Working with Files and Streams

File operations are deceptively simple until you face large datasets, concurrent writes, or cross-platform path differences. Production code needs to handle streaming, compression, encoding, and cleanup gracefully.

This section provides recipes for reading large files efficiently, watching directories for changes, compressing archives, rotating logs, and parsing configuration files. Solutions cover Python, Java, Node.js, and Bash for maximum flexibility.

beginner

Bash Scripting for DevOps Automation and System Tasks

How to write reliable Bash scripts for automating deployments, system monitoring, log rotation, and routine maintenance tasks

intermediate

AWS CLI Automation with Bash

Automate AWS resource provisioning, tagging, and cleanup using Bash scripts wrapped around the AWS CLI.

intermediate

Backup Rotation Script

Automate file backups with retention policies using a Bash script that rotates daily, weekly, and monthly snapshots.

advanced

Configure Firewall Rules with iptables

Set up basic firewall rules using iptables in Bash to filter traffic, block ports, and protect Linux servers.

intermediate

Log Rotation and Compression

Rotate and compress application logs with Bash to prevent disk exhaustion and simplify log retention.

beginner

Bash Loop Over Files

How to safely loop over files and directories in Bash, handling spaces, globs, and large file lists with correct patterns.

beginner

Monitor Disk Usage

Alert when disk space crosses thresholds using a Bash script that checks mount points and notifies operators.

intermediate

Bash Parallel Execution

How to run shell commands in parallel with xargs, GNU parallel, and Bash background jobs while controlling concurrency and collecting results.

intermediate

Parallel Job Execution with Bash

Run shell commands and scripts in parallel safely using xargs, parallel, or background jobs with concurrency control.

intermediate

SSH Key Management

Generate, rotate, and distribute SSH keys securely with Bash scripts for team and server access.

intermediate

Bash Text Processing

How to build capable text processing pipelines with grep, sed, awk, cut, sort, uniq, and tr for log analysis and data transformation.

intermediate

Compress and Decompress Files

How to handle ZIP, GZIP, and TAR archives programmatically.

beginner

Compress and Decompress Files with Gzip and Brotli

How to reduce file sizes for APIs, static assets, and log files using Gzip, Brotli, and zlib with streaming compression, content negotiation, and what works.

beginner

Copy and Move Files

How to copy and move files across platforms safely and efficiently.

beginner

Export Data to CSV/Excel

How to export structured data to CSV and Excel files efficiently.

intermediate

File Upload Validation

How to handle file uploads securely with size, type, and content validation.

intermediate

Generate PDFs

How to generate PDF documents programmatically from HTML, templates, or raw data.

beginner

Generate Temporary Files

How to create temporary files and directories safely with automatic cleanup across Python, Node.js, Java, and Bash.

beginner

Image Optimization

How to resize, compress, and optimize images for web performance.

beginner

Import Data from CSV/Excel

How to parse and import data from CSV and Excel files with validation.

intermediate

JavaScript Drag and Drop File Upload with HTML5 API

Implement native HTML5 drag and drop file upload in JavaScript

intermediate

Node.js File Upload Validation: Type, Size, and Content

Validate file uploads in Node.js with multer for type, size, and content

intermediate

Stream Process Large Files in Node.js Without Memory Issues

Process GB-sized files in Node.js using streams. Covers readline, transform streams, pipeline, backpressure, and chunk processing.

beginner

Batch Resize Images with Python

How to bulk resize and optimize images using Pillow and Python for web delivery.

beginner

Safely Extract Zip Files with Python

How to extract and validate zip archives securely using Python zipfile and shutil.

intermediate

Read Large Files

How to read large files efficiently without running out of memory.

beginner

Read and Write Files

How to read from and write to files safely across multiple programming languages.

intermediate

Rotate Log Files

How to implement log rotation by size, date, and count to prevent disk exhaustion across Python, Node.js, Java, and Linux systems.

intermediate

Process Large Files with Streams

How to read, transform, and write large files efficiently using streams without loading entire files into memory in Python, Node.js, and Java.

intermediate

Watch File Changes

How to monitor file system changes in real time.

intermediate

Write Large Files

How to write large files efficiently using buffered and streaming output.