Undocumented Features

Bash has some undocumented features. This Page aims to list all of them.

Educated bash users may know the expansion ${var,} ${var,,}, ${var^} and ${var^^} to change a string or character to upper and lowercase. However there are also the undocumented expansions ${var~} and ${var~~}, which will inverse the case, meaning lowercase letters becoming uppercase and vice-versa.

$ var=FooBar
$ echo ${var~~}
$ echo ${var~}

Declare has an undocumented -c flag, setting the variable to capcase, meaning the first character will always be uppercase while other ones will always be lowercase

$ declare -c var="hello World"
$ echo $var
Hello world
$ var=fooBar
$ echo $var

You can use brackets for defining code blocks after for:

$ for i in {1..3}; { echo $i; }

However, this syntax is deprecated and discouraged.

You could leave a comment if you were logged in.