This is an old revision of the document!


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

${var~~}

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~~}
fOObAR
$ echo ${var~}
fooBar

declare -c 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
Foobar

C-Style codeblocks

You can use brackets for defining code blocks after for, while, if, etc.

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

However, this syntax is deprecated and discouraged. </code>

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.1427963770.txt
  • Last modified: 2015/04/02 08:36
  • by stummi