Wednesday, October 3, 2012

grep pills


-H display file in the match 
--color  puts colors in the matched pattern 
-i case independent 
-vn grep all lines NOT containing the patters 
-w 18 looks for the number 18 ( non greedy behavior) 
-c count numbers of matchtes
-o only part that matches 
-A 1 return one line after the one matched

grep -rico

# eliminates all lines with the keyword "bad" in it

fgrep -v bad < filename

# grep unique words (e.g. hashtags like #machinelearning)

cat streamfile.txt | grep  -oh "#\w*" | sort | uniq

# grep with multiple patterns

grep -i -e pattern1 -e pattern2  

No comments:

Post a Comment