Bash 101 : Script default arguments


When using a bash script, we could have "replacement" default arguments if none are given.

Our example replaces the "$1" with replacement if no argument is provided:
 

The ":-" operator indicates that if the first argument of a program "$1" is not available, the "replacement" will be used in its stead.

Remark:

"$0" is the program's name and the "$1", "$2", ..., are its arguments

Comments

Leave as a comment:

Archive