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: and "Parameter Expansion" in man bash.
Also see

Leave a Reply