Searching Text Files Using pipe and grep


Use the grep command to search the contents of the listed text file or files. For example, in grep domain /etc/resolv.conf, the file resolv.conf is searched for the word domain and the lines containing that word are displayed.

Often, the output of one command is used as input for another command. The UNIX pipe character (|) is used for this purpose. The command ps -auxww | grep Finder executes the ps command and "pipes" its output (the process list) to the grep command. The grep command reads the process list as input, looking for the word Finder, and displays any lines containing Finder in the process list.




Apple Training Series. Mac OS X System Administration Reference, Volume 1
Apple Training Series: Mac OS X System Administration Reference, Volume 1
ISBN: 032136984X
EAN: 2147483647
Year: 2005
Pages: 258
Authors: Schoun Regan

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net