Previous topic |
Next topic |
Contents |
Contact z/OS |
Library |
PDF
Searching files by using pattern matching z/OS UNIX System Services User's Guide SA23-2279-00 |
|
One of the most common record-keeping operations is obtaining a sublist of a list. For example, you might want to list all the Watchmen comics that appear in the main comics list. The command to do this is grep. The simplest form of the grep command is:
where word is a particular sequence of characters
that you want to find, and file is your list of records. grep lists every line in the file that contains the given word. For
example:
lists every line in comics.lst that contains the word Watchmen.
As another example:
lists every line
in comics.lst that contains the sequence of
characters 1986. Presumably, this lists all the comics
that were published in 1986.
lists
all the comics published in July 1986.If the string of characters you want to search for contains a blank,
put single quotation marks (apostrophes) around the string; for example:
You can save a sublist created by grep in a file using
redirection:
|
Copyright IBM Corporation 1990, 2014
|