String Expansion (Curly Braces)

  • Build a series of string arguments, iterating over characters inside curly braces:
    string{A,B,C} = stringA stringB stringC
  • Example: creating name of nonexistent file (wildcards can't do this):
    % mv file{1,2}.html
    mv file1.html file2.html
    % cp file.html{,.bak}
    cp file.html file.html.bak
  • Not just for filenames!
    % mail {joe,jan,steve}@foo.org < file
    mail joe@foo.org jan@foo.org steve@foo.org < file
    % scp foo.com:sub/file{X,23,bar}.c .
    scp foo.com:sub/fileX.c foo.com:sub/file23.c foo.com:sub/filebar.c .
< previous  index  next >

Contact Jerry Peek