Shell script question

Hello all,

I have a script that has the following lines of code followed by other lines of code.. I'm not quite sure about the syntax in line #2, specifically ":-" ..what operation does it perform?

export IA_DAYS=$2
export IA_DAYS=${IA_DAYS:-90}
export IAW_DAYS=77
export AC=${1:-RP}

Thanks for your time

export IA_DAYS=${IA_DAYS:-90}

will attempt to assign the value in the IA_DAYS variable to IA_DAYS . If IA_DAYS is not defined/empty, then 90 is used. This technique is used to allow the variable to be set externally if the user desires, but ensures that it has a value.

In this particular case, it is used to set the value if $2 is not defined on the command line. It could also have been written:

export IA_DAYS=${2:-90}
1 Like

Thank you so much for that clear explanation!