My extremely short shell cheatsheet for things I do rarely enough to forget each time:
Process substitution:
bash: diff <(echo hello) <(echo world)
fish: diff (echo hello | psub) (echo world | psub)
Rsync directories:
rsync -a -v --dry-run other:dir/ dir/
Syncs the contents of dir (`/` needed)
Script exit handler:
bash:
function finish {
# exit handling code
}
trap finish EXIT # EXIT is special and works on normal exit as well as interrupts
Process substitution is one of those tricks that I don't have to look up each time as I find that I'm always using it - but that probably says more about the number of times that I'm given randomly ordered files that I need to compare with diff to figure out what's actually changed.