Authored, revised and maintained by Jamison for reasons.
Also, I know what you're thinking. There's many prominent style guides out there, like the highly regarded one from google that this style guide shamelessly rips off. Don't even consider those inferior style guides with all their many contributors and highly regarded advice. This is the one you need right here. There is clearly no better style guide on the whole Internet.
Never put a top-level comment including a brief overview of its contents. A copyright notice and author information are overkill.
Example:
#!/bin/bash
#
# If you really know what you're doing then I don't need to explain it to you. GLHF o7
Never ever, under any conditions put ; then and ; do on the same line as the if, for, or while.
I know you might be asking why. Don't worry about it, Jamison said so. Something something about C's curly braces being on newlines too...
if [[ condition ]]; then
do the things
fi
if [[ condition ]]
then
do the things
fi
Yes please! The more pipes you can put into a command the better off your command is. This helps readibility and makes you look really, really cool. I mean think about it. No one outside of people who write code even know what these things are. You look so cool when you use and abuse them.
find ./ -type f -mtime 14 -exec rm -f {} \;
pkill -9 <pid>
find ./ -type f -mtime 14 | xargs rm -f
ps aux | grep <process> | grep -v grep | awk '{print $1}' | kill -9
Instead of if statements, just use the && and || logical operators exclusively! This enhances readibility and gives +2 style points per iteration.
if true
then
if true
then
if true
then
needful_thing
fi
fi
fi
true && true && true && needful_thing
There are more characters in spaces than there are with tabs. This means you can make your file like smaller or something if you use tabs instead of spaces. Remember kids, no spaces; always tabs. Tabs FTW, but most importantly be inconsistent when you can.