Brace Expansion
The Bash feature „brace expansion“ is not present in sh. For example, when executing the following code in sh and in bash:
echo foo{1,2,3}
In sh, the output will be literal:
foo{1,2,3}
In bash it will be expanded to
foo1 foo2 foo3
Advice
To avoid brace expansion, the string can be put in quotes:
echo 'foo{1,2,3}'
Alternatively, the special characters in the string can be escaped:
echo foo\{1,2,3\}
This article is part of series "Shells and related Scripting Languages":
- GNU find hat keine Option „-older“ …
- Bourne to Bourne Again Shell Forward Compatibility
- Print XDG Desktop Definition for Application
- Find Files by Size given in Bytes
- Using sed or awk to ensure a specific last Line in a Text
- Make a Bourne Again Shell Script Log its Output to a File
- Maintaining Multi-Line „stat“ Formats using Bourne Again Shell
- Print all indented Lines following a non-indented Line