Chapter 9. File-Naming Shortcuts
In This chapter:
Using Filename Patterns
Using {} To Generate Arguments
Directory Naming Shorthand
Many commands accept multiple filenames on the command line, but typing ten or 20 names—even one or two, if they're long—can quickly become tedious. This chapter discusses several shortcuts that the shell provides for specifying filenames, so you can enter commands with less typing:
Pattern operators, for matching filenames
{}, for generating arguments using specific strings˜nameand=n, for referring to home directories and directory stack entries
Using Filename Patterns
The shell lets you specify filenames using a pattern, which is a notation that matches a group of filenames. Patterns are convenient because you can use them as a form of typing shorthand, and let the shell do the work of figuring out which filenames apply. You don't have to type them yourself. The pattern-matching characters are shown in Table 9-1.
Table 9-1. Filename-Matching Pattern Operators
Operator | Description |
|---|---|
| Match an arbitrary length sequence of characters |
| Match a single character |
| Match any character named between brackets |
| Match any character not named between brackets (tcsh only) |
| Match filenames not matching |
In order to see how various patterns work, it's helpful to have some sample filenames to work with. Assume you're in a directory containing the following files:
% ls Imakefile makefile part3 part8 xprog.h Makefile oot-greet.tar part4 part9 xprog.o Makefile.bak ...Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access