20261 post

  1. Write boring shell scripts

    A few conventions that make small Bash automation safer to rerun, easier to debug, and less surprising six months later.

    7 min

Notes

  1. Stop grep matching itself without grep -v grep

    ps aux | grep nginx always lists the grep nginx process too, which is why | grep -v grep is so common. Wrap one character of the pattern in brackets instead:…

    TIL
  2. Print a value in reusable shell quoting

    Bash 4.4 added the @Q parameter transformation, which quotes a value so it can be pasted back into a shell unchanged: Handy in logs: echo "running:…

    TIL