Bash: Guides and Practical Know-how | Page 15 | mironsoft Blog
Bash
-
Feb 23, 2025
Having a bats test suite for Bash scripts tells you nothing about which lines are actually executed. Code coverage with kcov closes that gap, shows line by line what tests really cover, and makes untested error paths visible long before they become a problem in production.
-
Feb 20, 2025
A backup that has never been tested is just a hypothesis. Bash backup scripts that combine rsync for incremental snapshots with tar for archived copies, clean up rotating backups according to a configurable retention policy, and run restore tests automatically make the difference between a data protection routine and a verified recovery process.
-
Feb 19, 2025
A cron job that runs overnight has to deliver a readable result by morning. Instead of scrolling through a log file, a Bash report builds a finished HTML page with tables, bars, and status badges directly, ready to send by mail or drop on an internal server, without PHP, Python, or a templating library.
-
Feb 12, 2025
jq makes JSON in the shell first class. Once you master filters, select(), map(), has(), and type checks, pass variables safely with --arg, and handle errors with try/catch, you can process API responses, config files, and log data directly in Bash, with no detour through Python or Node.
-
Feb 11, 2025
String hacks in Bash, file lists as whitespace-separated strings, configuration values as comma-separated fields, break systematically as soon as a value contains a special character. Arrays in Bash are the clean alternative: indexed arrays for ordered lists, associative arrays for key-value structures, slices for subsets and safe iteration for every use case.
-
Feb 11, 2025
The restricted shell rbash blocks cd, PATH changes, and calling programs through a path containing a slash. That is enough for simple, benign restrictions like an SFTP replacement, but it can be bypassed with documented techniques relatively easily. Anyone using rbash should know exactly what it covers and what needs additional hardening.
-
Feb 8, 2025
An entrypoint script with arrays and process substitution runs fine locally and fails inside an Alpine container with exec format error. The reason is BusyBox ash, which serves as /bin/sh in the default Alpine image instead of Bash and offers only a fraction of the familiar feature set.
-
Jan 31, 2025
tr is often seen as the simplest text tool in the shell and gets underrated because of it. Character classes, targeted deletion with -d and squeeze with -s make tr the fastest tool for input normalization, delimiter swapping and cleaning up control characters, often quicker to type and quicker to run than an equivalent sed command.
-
Jan 28, 2025
Since macOS Catalina, zsh has been the default login shell, while servers and CI environments keep relying on Bash. Anyone writing a script or a dotfile function meant for both shells has to know array indices, globbing and option names that differ fundamentally.
-
Jan 25, 2025
Processing logs in Bash means more than running grep and eyeballing the output. Time window filtering, structured error reporting, frequency analysis and combining grep, awk, sed and jq into efficient pipelines make the difference between reactive troubleshooting and proactive log monitoring.