bash commands

Fail if you don’t have any arguments

if [[ $# -eq 0 ]] ; then
  echo "I can't do that without a title"
  return
fi

Date formats

year=$(date +'%Y')
slug="$(date +'%y%m%d')"

Case statements

if [[ $# -eq 0 ]] ; then
    echo 'some message'
    exit 0
fi

case "$1" in
    1) echo 'you gave 1' ;;
    *) echo 'you gave something else' ;;
esac

Mostly Katie explaining things to herself.

© 2022