Shell [Scripting] Style Guide
google.github.io
google.github.io
Some tips of my own:
Adding `2>/dev/null` or `>/dev/null 2>&1`after most commands with expected or just plain useless output can make writing headless scripts very easy, it also comes in very handy when trying to shut up some basic utilities.
A handy function:
execute() {
pkill -x "$1"
{
sleep 0.1
"$@" &
}
} >/dev/null 2>&1
`set --` before running a command can be used to remove all excess whitespace (making parsing dead easy).And last but not least always using printf instead of echo makes your scripts 1000x cooler :)
0. https://github.com/dylanaraps/pure-sh-bible 1. https://github.com/dylanaraps/pure-bash-bible