home | O'Reilly's CD bookshelfs | FreeBSD | Linux | Cisco | Cisco Exam  


Unix Power ToolsUnix Power ToolsSearch this book

28.4. Build Strings with { }

I've been finding more and more uses for the {} pattern-expansion characters in csh , tcsh, zsh, and bash. They're similar to *, ?, and [ ] (Section 33.2), but they don't match filenames the way that *, ?, and [ ] do. You can give them arbitrary text (not just filenames) to expand -- that "expand-anything" ability is what makes them so useful.

Here are some examples to get you thinking:

In bash, the complete-into-braces editor command (which is bound to the M-{ key sequence by default in Emacs mode) expands a string into a list of matching filenames in braces. For example:

$ ls pr*
prog1.c   prog2.c   program1.c   program2.c
$ cc pr META{
$ cc pr{og1.c,og2.c,ogram1.c,orgram2.c}

Then you can edit the brace expression.

-- JP



Library Navigation Links

Copyright © 2003 O'Reilly & Associates. All rights reserved.