Read first line of a file into a variable

To put the first line of the file /etc/sympa/cookie into the variable $COOKIE use the read builtin:

~ read -r COOKIE < /etc/sympa/cookie

Verify environment variable

Check that environment variable API_USER is present and not empty:

: "${API_USER:?Please set API_USER environment variable}"

Substitutions

Default value for first command line parameter:

DATE=${1:2019-January}

The substitution can be any shell syntax, even a command:

DATE=${1:-`date +"%Y-%B"`}

History

Resources

How To Use Bash History Commands and Expansions