If you're searching a long file to find a particular word or name, or you're running a program like ls -l and you want to filter some lines, here's a quick way to narrow down the search. As an example, say your phone file has 20,000 lines like these:
Smith, Nancy:MFG:50 Park Place:Huntsville:(205)234-5678
and you want to find someone named Nancy. When you see more information, you know you can find which of the Nancys she is:
Use the C shell'sand to cut out lines you don't want. For example, about a third of the Nancys are in Huntsville, and you know she doesn't work there:
The shell shows the command it's executing: the previous command (
Okay. You know Nancy doesn't work in the MFG or SLS groups, so delete those lines, too:
If the matching pattern has anything but letters and numbers in it, you'll have to understandand sed . Most times, though, this quick-and-dirty way works just fine.