Variable expansion is a powerful and important Bash feature. It allows for more advanced, convenient manipulation of text without invoking another process. Some expansion types will only work for newer versions of Bash. These limitations are noted where relevant.
Note: Each type of expansion is described in the order that Bash interprets it.
foo{bar,}
→ "foobar foo"
and foo{,bar}
→ "foo foobar"
{a..m}
→ a b c d e f g h i j k l m
{{a..z},{A..Z}}
→ a b c d e f g h i j k l m n o p q r s t u v w x y z A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
{001..010}
→ 001 002 003 004 005 006 007 008 009 010
{1..10..2}
→ 1 3 5 7 9
{a..m..3}
→ a d g j m
These operations all occur at the same time, in left-to-right order:
Compatibility depends on OS. It's used to avoid subshells, or use the filesystem as an API.