From 9f36a2ebdfc07804a99e3fa41c8bec867e47105d Mon Sep 17 00:00:00 2001 From: wxy Date: Fri, 29 Jan 2016 07:00:55 +0800 Subject: [PATCH] PUB:20151127 Linux or UNIX grep Command Tutorial series 3--Search Multiple Words or String Pattern Using grep Command @runningwater --- ...iple Words or String Pattern Using grep Command.md | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) rename {translated/tech/Linux or UNIX grep Command Tutorial series => published}/20151127 Linux or UNIX grep Command Tutorial series 3--Search Multiple Words or String Pattern Using grep Command.md (81%) diff --git a/translated/tech/Linux or UNIX grep Command Tutorial series/20151127 Linux or UNIX grep Command Tutorial series 3--Search Multiple Words or String Pattern Using grep Command.md b/published/20151127 Linux or UNIX grep Command Tutorial series 3--Search Multiple Words or String Pattern Using grep Command.md similarity index 81% rename from translated/tech/Linux or UNIX grep Command Tutorial series/20151127 Linux or UNIX grep Command Tutorial series 3--Search Multiple Words or String Pattern Using grep Command.md rename to published/20151127 Linux or UNIX grep Command Tutorial series 3--Search Multiple Words or String Pattern Using grep Command.md index 9af1afa163..ed44522d70 100644 --- a/translated/tech/Linux or UNIX grep Command Tutorial series/20151127 Linux or UNIX grep Command Tutorial series 3--Search Multiple Words or String Pattern Using grep Command.md +++ b/published/20151127 Linux or UNIX grep Command Tutorial series 3--Search Multiple Words or String Pattern Using grep Command.md @@ -1,5 +1,6 @@ -使用 grep 命令来搜索多个单词/字符串模式 +grep 命令系列:使用 grep 命令来搜索多个单词 ================================================================================ + 要使用 grep 命令来搜索多个字符串或单词,我们该怎么做?例如我想要查找 /path/to/file 文件中的 word1、word2、word3 等单词,我怎么样命令 grep 查找这些单词呢? [grep 命令支持正则表达式][1]匹配模式。要使用多单词搜索,请使用如下语法: @@ -10,7 +11,7 @@ $ grep 'warning\|error\|critical' /var/log/messages -仅仅只是要匹配单词的话,可以加上 -w 选项参数: +仅仅只是要匹配单词(即该词两侧是单词分界符,针对西方以空格分隔的语言而言)的话,可以加上 -w 选项参数: $ grep -w 'warning\|error\|critical' /var/log/messages @@ -26,7 +27,7 @@ egrep 命令可以跳过上面的语法格式,其使用的语法格式如下 ![Fig.01: Linux / Unix egrep Command Search Multiple Words Demo Output](http://s0.cyberciti.org/uploads/faq/2008/04/egrep-words-output.png) -Fig.01: Linux / Unix egrep 命令查找多个单词输出例子 +图一: Linux / Unix egrep 命令查找多个单词输出例子 -------------------------------------------------------------------------------- @@ -34,8 +35,8 @@ via: http://www.cyberciti.biz/faq/searching-multiple-words-string-using-grep/ 作者:Vivek Gite 译者:[runningwater](https://github.com/runningwater) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 -[1]:http://www.cyberciti.biz/faq/grep-regular-expressions/ \ No newline at end of file +[1]:https://linux.cn/article-6941-1.html \ No newline at end of file