2 ms·
This pairs extremely well with dylan's Pure Bash/sh Bible [1], both, combined with admittedly way too many hours browsing random people's dotfiles can exponenti
by reayn 5y ago
This pairs extremely well with dylan's Pure Bash/sh Bible [1], both, combined with admittedly way too many hours browsing random people's dotfiles can exponentially increase your skills with shells scripting.
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 https://github.com/dylanaraps/pure-sh-bible
1. https://github.com/dylanaraps/pure-bash-bible https://github.com/dylanaraps/pure-bash-bible
- wodenokoto 5y agoWhy is printf better than echo?