- 论坛徽章:
- 0
|
- -m NUM, --max-count=NUM
- Stop reading a file after NUM matching lines. If the input is standard input from a regular file, and NUM
- matching lines are output, grep ensures that the standard input is positioned to just after the last matching line
- before exiting, regardless of the presence of trailing context lines
复制代码 根据上面的帮助内容,grep在从文件流中获取指定匹配行后将文件指针定位到最后一此匹配行的后续行上- # cat file
- slkd
- eioc
- weic
- eoc
- lweoijxlk
- skeoicj
- lksdoi
- # while grep -m 2 "^[se]";do echo '-->find';done <file <--- 经测试最后一次输出为什么有重复部分?如果"-m 1",会导致while陷入死循环,why?
- slkd
- eioc
- -->find
- eoc
- skeoicj
- -->find
- skeoicj
- -->find
复制代码 希望能有人答疑解惑? |
|