Bash command on a variable

What does the following bash command do?

"${ctp// /}"

I want to check whether a variable is composed of an empty string or is all spaces, so that I can assign a default value.

>Solution :

It removes any space characters.

Parameter Expansion expands parameters: $foo, $1. You can use it to perform string or array operations: "${file%.mp3}", "${0##*/}", "${files[@]: -4}". They should always be quoted.
See: http://mywiki.wooledge.org/BashFAQ/073 and "Parameter Expansion" in man bash.
Also see http://wiki.bash-hackers.org/syntax/pe

Leave a Reply