Problem
You have a bash script that accepts parameter(s) but you want to give a default value for a missing parameter.
Solution
For example you have a script that accepts a parameter with the year and month (ie 201703), but you want to give it a default of two months ago if the parameter is missing.
#!/bin/bash LM=$(date -d '2 month ago' +%Y%m) YEARMONTH=${1:-${LM}} echo $YEARMONTH