Dedicated fd for structured logging bash
Open fd 3 to a file, write to it independently of stdout, then close it
exec 3>>audit.log; echo "$(date -Is) start" >&3; exec 3>&-
more bash
all 12 commands →
zsh recursive glob and batch rename
setopt extendedglob; print -l **/*(.); autoload zmv; zmv '(*).txt' '$1.bak'
Strict mode with safe IFS
set -euo pipefail; IFS=$'\n\t'
Cleanup temp dir via trap
tmp=$(mktemp -d); trap 'rm -rf "$tmp"' EXIT INT TERM
Diff two command outputs
diff <(kubectl get cm a -o yaml) <(kubectl get cm b -o yaml)
Read file lines into array safely
mapfile -t lines < file.txt; printf '%s\n' "${lines[@]}"