Topic · 20 articles
Unix Shell & Tooling
The shell is a programming language that punishes you for treating it like one, and most production scripts are one odd filename or one failed producer away from doing something stupid. The fixes are old, small, and almost never used.
Start with the four that stop scripts lying and deleting the wrong things: pipeline exit status, trap, null-terminated xargs, and flock. Then awk for the log questions you were about to write Python for, and the tools that keep a process alive or a connection warm.
Start here
Read these first, in this order.
- 01

Tip · 2026-08-03
Your shell pipeline succeeded because the last command was polite
A failed producer can disappear behind a successful consumer. RodHat explains pipeline exit status, pipefail, PIPESTATUS, and how to stop backup scripts from lying.
- 02

Tip · 2026-08-21
Your shell scripts crash. trap EXIT is why the mess does not have to survive.
The shell trap builtin intercepts signals and the EXIT pseudo-signal to run cleanup code regardless of how a script dies. Most scripts skip it entirely. Here is how to use it correctly, including the subshell gotchas and the ERR trap edge cases that bite people.
- 03

Tip · 2026-07-24
find | xargs is a filename injection bug you've been shipping for years
Whitespace, newlines and quotes in filenames turn the standard find-pipe-xargs idiom into something that deletes the wrong files. -print0 and -0 fix it, find -exec + fixes it better, and there's one case where only one of them works.
- 04

Tip · 2026-08-09
Your cron job is running twice and that's why the numbers are wrong
A job that usually takes four minutes on a five-minute schedule will eventually take six, and then you have two copies racing. flock fixes it in one line, and the pidfile you were about to write instead is broken in ways flock isn't.
- 05

Tip · 2026-08-01
awk has hash maps, and that's why you don't need the Python script
Most people's awk stops at print $7. Associative arrays, END blocks and a two-line accumulator turn it into the right tool for ninety percent of the log questions people currently write a script for, and it runs on a box with nothing installed.
- 06

Tip · 2026-08-18
nohup, disown, setsid: what each actually does and which one you want
Three tools for keeping a process alive after you close the terminal. They do not do the same thing. Here is the kernel-level difference, and when each one applies.
The syscalls underneath
Version introduced, sourced from the man page. Full cards in the syscall reference, or check your kernel.
| Interface | Since | What it does |
|---|---|---|
| flock(2) | 4.2BSD; Linux 2.0 | Apply or remove an advisory whole-file lock tied to an open file description. |
More console tips (5)
- socat is the Swiss Army knife you keep reaching past
- The six rsync flags worth knowing, and the one that builds you free snapshots
- Five shell one-liners I actually use, not the ones that show up in every 'top 10' list
- Process supervision is a 40-line problem. It has been solved since 1997.
- Your ssh is reconnecting every single time. It doesn't have to.
Rod's tales (4)
- The daemon wrote the files. The backup was empty.
- The pipeline succeeded. We found out from a customer.
- The postrotate script worked. We had no logs.
- The billing job ran twice for six weeks and the totals still balanced
MOTD (5)
- Ubuntu 26.10 finishes what 26.04 started: GNU coreutils is now opt-in
- `sudo` wrote its last heap overflow in C. The Rust rewrite shipped.
- POSIX finally standardized .PHONY. Only took thirty years of everyone using it.
- Git's SHA-256 transition is finally not vaporware
- Another vendor decided the CLI was holding their users back. They're wrong.