1、^linux 以linux开头的行
2、 php$ 以php结尾的行
3、 . 匹配任意单字符
4、 .+ 匹配任意多个字符
5、 .* 匹配0个或者多个字符
cd /var/www/html
touch test.php
vim test.php
php is very much
my age is 30
linux is very much
x
my ip is 192.168.100.1
mysql is very much
y
Linux is very much
i like linux very much
i like linux
linux is veryvery much
linux is veryveryvery much
linux is veryveryveryvery much
linux is veryveryveryveryvery much
linux is veryveryveryveryveryvery much
root@localhost:/var/www/html# grep -cni 'linux' test.php
root@localhost:/var/www/html# grep -n 'linux' test.php|wc -l
root@localhost:/var/www/html# grep -v 'linux' test.php
root@localhost:/var/www/html# grep -E '^linux' test.php
root@localhost:/var/www/html# grep -E 'linux$' test.php
root@localhost:/var/www/html# grep -En '.' test.php
root@localhost:/var/www/html# grep -E '.*' test.php
root@localhost:/var/www/html# grep -E '.*linux.*' test.php
root@localhost:/var/www/html# grep -E ' .+linux.+' test.php
root@localhost:/var/www/html# grep -E ' ^$' test.php
root@localhost:/var/www/html# grep -E ' ^.$' test.php
root@localhost:/var/www/html# grep -En ' [0-9]+' test.php
root@localhost:/var/www/html# grep -E ' [0-9]+\.[0-9]+\.[0-9]+\.[0-9]+' test.php
root@localhost:/var/www/html# grep -E '(very)+' test.php
root@localhost:/var/www/html# grep -E ' (very){2}' test.php
root@localhost:/var/www/html# grep -E ' (very){2,4}' test.php
[root@db3 yansiyu]# grep -E --color '\b(very){3,4}\b' test.php #查询行中包含3至4个very的句子
linux is veryveryvery much
linux is veryveryveryvery much