What to use

Use the shellcheck program!

The script should start with a line #!/usr/bin/env bash

To make the script runnable use chmod u+x script.sh

system_name=$(uname)
script_path=$(realpath $0)
if [ $# -eq 0 ]; then echo "usage: ..."; fi
#compare numbers using -eq -ne -lt -le -gt -ge
#compare strings using = != < <= > >=
while [ $# -ne 0 ]; do shift; done
#remove the first argument with shift
array=( 'a' 'b' 'c d' )
echo "Array of ${#array[@]} contains: ${array[*]}"
for element in "${array[@]}"; do
    echo "Value: $element"
    if   [ "$element" = "c d" ]; then break;
    elif [ "$element" = "a" ]; then continue;
    echo "Only the element 'b' is printed here"
done
unset array
if [ -f "file.txt" ]; then cat "file.txt"; fi
#-f file, -d directory, -z variable ... is defined?
function verbose { if [ "$v" ]; then color 'note' "$@"; fi }
exit 0
#abandon script

Manual pages on: If Case While

Do not use

res=`command "test"` #use res=$(command "test")
. "something.sh" #use source "something.sh"
if [ "$a" == "test" ]; #use = to compare strings
if [ $a && $b ]; #use [ $a ] && [ $b ];

Zdroje