What does the colon dash “:-” mean in bash [duplicate]

It’s a parameter expansion, it means if the third argument is null or unset, replace it with what’s after :-

$ x=
$ echo ${x:-1}
1
$ echo $x

$

There’s also another similar PE that assign the value if the variable is null:

$ x=
$ echo ${x:=1}
1
$ echo $x
1

Check http://wiki.bash-hackers.org/syntax/pe

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)