Shell Scripting

Effective Shell is an ebook on shell scripting principles1.

unix-shell-script-tactics is a shell style guide that lays out common script patterns.

ShellCheck is a linter for shell scripts.

dylanaraps/pure-sh-bible - A collection of pure POSIX sh alternatives to external processes.

Appending multiple lines to a file

tee -a FILE << EOF > /dev/null
echo "line 1"
echo "line 2"

Start custom scripts with ‘,’

If you create custom scripts in a PATH’d bin directory, prepend them with a , to keep them separate from the standard binaries and also allow easy access via tab completion2.

Get path relative to script path

script_root = $(dirname $(realpath $0))


Kerr, D. Effective Shell. (2022).
Rhodes, B. Start all of your commands with a comma. at (2009).

Links to this note