grep -A -B | ggrep | grep -r


greo -A -B line after before
grep -- -1000 # grep negative value

----------------
bash-3.00# grep 15:[12][70] f[123].txt
f1.txt:root console Apr 10 15:17 (:0)
f1.txt:root pts/3 Apr 10 15:20 (:0.0)
f2.txt:root console Apr 10 15:17 (:0)
f2.txt:root pts/3 Apr 10 15:20 (:0.0)
f3.txt:root console Apr 10 15:17 (:0)
f3.txt:root pts/3 Apr 10 15:20 (:0.0)
----------
bash-3.00# grep -l 'text' f*
f.txt
f1.txt
f2.txt
f3.txt


-----------
 * e - go to the end of the current word.
 * E - go to the end of the current WORD.
 * b - go to the previous (before) word.
 * B - go to the previous (before) WORD.
 * w - go to the next word.
 * W - go to the next WORD.
grep -A <N> "string" FILENAME
The following example prints the matched line, along with the 3 lines after it.
================
$ export GREP_OPTIONS='--color=auto' GREP_COLOR='100;8'

$ grep this demo_file
this line is the 1st lower case line in this file.
Two lines above this line is empty.
And this is the last line.
For Solaris 
ggrep -A 10

For GNUBDS
grep -A 10 -B 10


When you want to search in all the files under the current directory and its sub directory
$ grep -r "ramesh" *

Invert match using grep -v


Comments

Popular posts from this blog

HAproxy logging

tomcat catalina coyote jasper cluster

NFS mount add in fstab _netdev instead of default | firewall-cmd --list-all