Searching for and Extracting Data
The grep
command uses regular expressions and is helpful in locating data. The grep
utility locates files by scanning their contents. The grep
program also returns some of the data included in files, which can be useful if you want to extract just a little data from a file or from a program’s output. As its name suggests, find
locates files. It uses surface features, such as the filename and the file’s date stamps. Another command, wc
, provides basic statistics on text files. To extract individual data items from a file’s lines, the cut
command is useful. Two additional commands, sort
and cat
, allow the display of resulting data to be manipulated, which can be helpful in your search.
Using grep
The grep
command searches for files that contain a specified string and returns the name of the file and (if...