Show Line Numbers Where Words Appear in Files


-n

The grep command shows you the line containing the term for which you're searching, but it doesn't really tell you where in the file you can find that line. To find out the line number, utilize the -n (or --line-number) option.

$ grep -n pain * fiery inferno in space.txt:56:watch the paint peel, three_no_more_forever.txt:19:all alone and in pain the speed of morning.txt:66:of a Chinese painting. 8 hour a day.txt:78:nice paint job too ghost pain.txt:32:Subject: ghost pain 


Now that you know the line numbers for each instance of the string pain, it is a simple matter to go directly to those lines in virtually any text editor. Nice!



Linux Phrasebook
Linux Phrasebook
ISBN: 0672328380
EAN: 2147483647
Year: 2007
Pages: 288

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