Linux 中 grep命令的 -m选项

 

001、

[root@PC1 test2]# ls
a.txt
[root@PC1 test2]# cat a.txt
0|2     03      0|4
07      08      09
17      1|8     19
22      23      24
27      2|8     29
[root@PC1 test2]# grep "|" a.txt
0|2     03      0|4
17      1|8     19
27      2|8     29
[root@PC1 test2]# grep -m 1 "|" a.txt         ## -m选项限制输出的行数,第一次匹配到就立刻停止搜索
0|2     03      0|4
[root@PC1 test2]# grep -m 2 "|" a.txt
0|2     03      0|4
17      1|8     19

image

。 

 

posted @ 2026-06-15 17:03  小鲨鱼2018  阅读(4)  评论(0)    收藏  举报