Friday, January 15, 2016

NVL equivalent in Unix

Sometimes, we want to assign an alternate value to a variable if it were null. I recently found that it has a one liner in Unix.

var1=${new_var1:-$default_var1}
 Which means if $new_var1 is not null, use it else use the $default_var1.