Variable on If Statement

Hi,

I am tasked to modify soem script and I come accross a line which I dont fully understand. I tried searching online but I couldnt get a good explanation on it.

Here it the part of the code:

 
PAY_RT=`cat $TEMPFILE | cut -f2 -d","`
 
if [ ${PAY_RT:-BLANK = 'P' ];
then
     PAY_RT=R
fi

What is the colon (:slight_smile: and hypen (-) means on the if statement? I never used this on any of my if statement before.

There are also variation of :

if [ ${PAY_AMNT:-"00" = "000" ];
then
     PAY_AMNT=00
fi
 

It is called "parameter expansion".

An extract from the Korn shell man page:

Although your code seems to be missing the closing }.

Anything of the form ${...} is a bash parameter substitution, the one you are seeing should read ${PAY_AMNT:-"00"} and could be read substitute this marker with the value of PAY_AMNT or if PAY_AMNT is null use "00"

That really helps! Thanks.