I am new to bash but have done lots of PHP, and Javascript.
Is there some sort of equivilent to this PHP?
$default = 10;
$var = (!$var) ? $default : $var;
Thanks
Yes, it does:
var=${var:-10}
Even with other variables:
unset var
export def=99
echo ${var:-${def}} # gives '99'
export var=7
echo ${var:-${def}} # gives '7'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With