Expansion
[me@linuxbox ~]$ echo $(((5**2) * 3))
75
Here is an example using the division and remainder operators. Notice the effect of inte-
ger division:
[me@linuxbox ~]$ echo Five divided by two equals $((5/2))
Five divided by two equals 2
[me@linuxbox ~]$ echo with $((5%2)) left over.
with 1 left over.
Arithmetic expansion is covered in greater detail in Chapter 34.
Brace Expansion
Perhaps the strangest expansion is called brace expansion. With it, you can create multi-
ple text strings from a pattern containing braces. Here's an example:
[me@linuxbox ~]$ echo Front-{A,B,C}-Back
Front-A-Back Front-B-Back Front-C-Back
Patterns to be brace expanded may contain a leading portion called a preamble and a
trailing portion called a postscript. The brace expression itself may contain either a
comma-separated list of strings, or a range of integers or single characters. The pattern
may not contain embedded whitespace. Here is an example using a range of integers:
[me@linuxbox ~]$ echo Number_{1..5}
Number_1 Number_2 Number_3 Number_4 Number_5
Integers may also be zero-padded like so:
[me@linuxbox ~]$ echo {01..15}
01 02 03 04 05 06 07 08 09 10 11 12 13 14 15
[me@linuxbox ~]$ echo {001..15}
001 002 003 004 005 006 007 008 009 010 011 012 013 014 015
A range of letters in reverse order:
71