magbo system

Bash cheatsheet

files=(Screen*.png)
if [ $files = "Screen*.png" ]; then
  echo "No match"
else
  # Override or append
  files[2]="test1"

  # Remove
  files=("${files[@]:0:1}" "${files[@]:3:4}")

  # Length
  echo ${#files[@]}

  for file in "${files[@]}"; do
    echo "$i"
  done

  for ((i = 0; i < ${#files[@]}; i++)); do
    echo "${files[i]}"
  done
fi
case "$a" in
"a")
  echo "a"
  ;;
"b")
  echo "b"
  ;;
*)
  echo "else"
  ;;
esac
path="/var/www/html"
echo ${path##*/} # Last directory
# # from beginning, shortest match
# ## from beginning, longest match
# % from end, shortest match
# %% from end, longest match