DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH
 

(bash.info) Brace Expansion

Info Catalog (bash.info) Shell Expansions (bash.info) Tilde Expansion
 
 3.5.1 Brace Expansion
 ---------------------
 
 Brace expansion is a mechanism by which arbitrary strings may be
 generated.  This mechanism is similar to FILENAME EXPANSION (
 Filename Expansion), but the filenames generated need not exist.
 Patterns to be brace expanded take the form of an optional PREAMBLE,
 followed by either a series of comma-separated strings or a sequence
 expression between a pair of braces, followed by an optional POSTSCRIPT.
 The preamble is prefixed to each string contained within the braces, and
 the postscript is then appended to each resulting string, expanding left
 to right.
 
    Brace expansions may be nested.  The results of each expanded string
 are not sorted; left to right order is preserved.  For example,
      bash$ echo a{d,c,b}e
      ade ace abe
 
    A sequence expression takes the form `{X..Y[..INCR]}', where X and Y
 are either integers or single characters, and INCR, an optional
 increment, is an integer.  When integers are supplied, the expression
 expands to each number between X and Y, inclusive.  Supplied integers
 may be prefixed with `0' to force each term to have the same width.
 When either X or Y begins with a zero, the shell attempts to force all
 generated terms to contain the same number of digits, zero-padding
 where necessary.  When characters are supplied, the expression expands
 to each character lexicographically between X and Y, inclusive, using
 the default C locale.  Note that both X and Y must be of the same type.
 When the increment is supplied, it is used as the difference between
 each term.  The default increment is 1 or -1 as appropriate.
 
    Brace expansion is performed before any other expansions, and any
 characters special to other expansions are preserved in the result.  It
 is strictly textual.  Bash does not apply any syntactic interpretation
 to the context of the expansion or the text between the braces.  To
 avoid conflicts with parameter expansion, the string `${' is not
 considered eligible for brace expansion.
 
    A correctly-formed brace expansion must contain unquoted opening and
 closing braces, and at least one unquoted comma or a valid sequence
 expression.  Any incorrectly formed brace expansion is left unchanged.
 
    A { or `,' may be quoted with a backslash to prevent its being
 considered part of a brace expression.  To avoid conflicts with
 parameter expansion, the string `${' is not considered eligible for
 brace expansion.
 
    This construct is typically used as shorthand when the common prefix
 of the strings to be generated is longer than in the above example:
      mkdir /usr/local/src/bash/{old,new,dist,bugs}
    or
      chown root /usr/{ucb/{ex,edit},lib/{ex?.?*,how_ex}}
 
Info Catalog (bash.info) Shell Expansions (bash.info) Tilde Expansion
automatically generated byinfo2html