“每天一命令之grep”的版本间的差异

来自linux中国网wiki
跳到导航 跳到搜索
第28行: 第28行:
 
               letters, digits, and the underscore.  This option has no effect if -x is also specified.
 
               letters, digits, and the underscore.  This option has no effect if -x is also specified.
 
</pre>
 
</pre>
 +
 +
=see also=
 +
[https://blog.51cto.com/future/88653 grep 参数使用和实例]
 +
  
  
[https://blog.51cto.com/future/88653 grep 参数使用和实例]
+
[https://blog.csdn.net/mmbbz/article/details/51035401 Linux: grep多个关键字“与”和“或”]
 
  [[category:shell]]
 
  [[category:shell]]

2020年1月14日 (二) 08:28的版本

常用参数

#多个and 
ps -ef | grep  -E 'tomcat1 |tomcat2 |grep -v grep '

grep -rn   sth  somefiles #比dat 好

##并  fstab 文件中 有  /data  和 UUID 关键词
grep  /data /etc/fstab | grep UUID 


grep 同时满足多个关键字和满足任意关键字
① grep -E "word1|word2|word3"   file.txt
   满足任意条件(word1、word2和word3之一)将匹配。
② grep word1 file.txt | grep word2 |grep word3
   必须同时满足三个条件(word1、word2和word3)才匹配。


find & grep 总结

精准 非贪婪匹配

 -w, --word-regexp         强制 PATTERN 仅完全匹配字词
              Select  only  those  lines containing matches that form whole words.  The test is that the matching substring must either be at the beginning of the line, or preceded by a
              non-word constituent character.  Similarly, it must be either at the end of the line or followed by a non-word  constituent  character.   Word-constituent  characters  are
              letters, digits, and the underscore.  This option has no effect if -x is also specified.

see also

grep 参数使用和实例


Linux: grep多个关键字“与”和“或”