Saturday, March 21, 2009

GREP command

grep india /usr/share/dict/words = looks for the word 'india' in dictionary
grep “word” filename = prints lines with the “word ” in them
grep -n “word” filename = line numbers with the word in them printed
grep -vn “word” filename = lines without the “word” in them
grep -c “word” filename = total no. of occurrences of “word”
grep -n “word” * = lists all lines from all files that contain “word”
grep -x “word” * = only “word” a line
grep word filename = searchers for the word in the file
grep -i word filename = searchers for the word in the file
grep -i word1 word2 filename = searchers for the word in the file
groups = list of groups

No comments:

Post a Comment