Tuesday, March 12, 2013

How could you set default value for a variable in UNIX?

Set default values for variables using ":-".

VARIABLE=${1:-DEFAULT_VALUE}

sets VARIABLE with the value of 1st Arg to DEFAULT_VALUE, if 1st arg is not entered.

No comments :