grep

grep参数

1.   -c 显示匹配的行数(就是显示有多少行匹配了);

2.   -n 显示匹配内容所在文档的行号;

3.   -i 匹配时忽略大小写;

4.   -s 错误信息不输出;

5.   -v 输出不匹配内容;

6.   -x 输出完全匹配内容;

7.   \ 忽略表达式中字符原有含义;

8.   ^ 匹配表达式的开始行;

9.   $ 匹配表达式的结束行;

10. \< 从匹配表达式的行开始;

11. \> 到匹配表达式的行结束;

12. [ ] 单个字符(如[A] 即A符合要求);

13. [ - ] 范围;如[A-Z]即A,B,C一直到Z都符合要求;

14. . 所有的单个字符;

15. * 所有字符,长度可以为0;

grep list file

xargs can read items from a file (like your files.txt list) with it's option:

   --arg-file=file
   -a file
          Read items from file instead of standard input.  If you use this
          option, stdin remains unchanged when commands are  run.   Other‐
          wise, stdin is redirected from /dev/null.
So this should work too:

xargs -a files.txt grep -i 'foo'
or for spaces in filenames

xargs -d'\n' -a files.txt grep -i 'foo'
xargs -I{} -a files.txt grep -i 'foo' {}

或者

for i in $(cat files.txt); do grep -i 'foo' $i ; done

你可能感兴趣的:(grep)