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.

This website uses cookies for visitor traffic analysis. By using the website, you agree with storing the cookies on your computer.More information
You could leave a comment if you were logged in.
  • undocumented_features.txt
  • Last modified: 2015/04/02 11:28
  • by stummi