[root@mhc regular]# cat a.txt|grep goooooogle
goooooogle yes!
[root@mhc regular]#
[root@mhc regular]#
[root@mhc regular]# cat a.txt|grep -A2 goooooogle
goooooogle yes!
go! go! Let's go.
# I am VBird
[root@mhc regular]# cat a.txt|grep -B2 goooooogle
I like dog.
google is the best tools for search keyword.
goooooogle yes!
[root@mhc regular]#
[root@mhc regular]#
[root@mhc regular]#
[root@mhc regular]# cat a.txt|grep -A2 -B2 goooooogle
I like dog.
google is the best tools for search keyword.
goooooogle yes!
go! go! Let's go.
# I am VBird

-n 打印行数

-i 不论大小写

 

[root@mhc regular]# cat -n a.txt |head -n 10 |tail -n 6
     5    However, this dress is about $ 3183 dollars.
     6    GNU is free air not free beer.
     7    Her hair is very beauty.
     8    I can't finish the test.
     9    Oh! The soup taste good.
    10    motorcycle is cheap than car.

grep -v '^$' a.txt|grep -v '^#'

egrep -v '^$|^#' a.txt