Hi everybody,


I decided to ask it here because i didn't know how to ask it on google, i want to know what does this line do:

: ${dummy_msg:="Nothing started."}

Thanks.

There ought to be a space between : and the $.
Anyways, what it does it checks for the existence of a variable called dummy_msg. If it does not exist (not defined) or is empty, it will set the value of the same as 'Nothing started'.

Consider this:

nilesh@Linux ~ $ set | grep dummy
nilesh@Linux ~ $ : ${dummy_msg:="Nothing started."}
nilesh@Linux ~ $ set | grep dummy
dummy_msg='Nothing started.'
nilesh@Linux ~ $ dummy_msg=
nilesh@Linux ~ $ set | grep dummy
dummy_msg=
nilesh@Linux ~ $ : ${dummy_msg:="Nothing started."}
nilesh@Linux ~ $ set | grep dummy
dummy_msg='Nothing started.'

ok man, thanks.

But, couldn't i do the same thing just using ${dummy_msg:="Nothing started."}?

Thanks.

You can, but it will complain something like command not found.
Because bash will first check for value of dummy_msg. If empty/unset, set the default value given, and try to execute a command with that name.

This question has already been answered. Start a new discussion instead.