From 25e49a9f31361b29cf02626714c10673b4c9524a Mon Sep 17 00:00:00 2001 From: runningwater Date: Sun, 20 Dec 2015 15:41:48 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BF=BB=E8=AF=91=E5=AE=8C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...rds or String Pattern Using grep Command.md | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/sources/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/sources/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 index bd58e78535..9af1afa163 100644 --- a/sources/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/sources/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 @@ -1,32 +1,32 @@ -(翻译中 by runningwater)Search Multiple Words / String Pattern Using grep Command +使用 grep 命令来搜索多个单词/字符串模式 ================================================================================ -How do I search multiple strings or words using the grep command? For example I'd like to search word1, word2, word3 and so on within /path/to/file. How do I force grep to search multiple words? +要使用 grep 命令来搜索多个字符串或单词,我们该怎么做?例如我想要查找 /path/to/file 文件中的 word1、word2、word3 等单词,我怎么样命令 grep 查找这些单词呢? -The [grep command supports regular expression][1] pattern. To search multiple words, use following syntax: +[grep 命令支持正则表达式][1]匹配模式。要使用多单词搜索,请使用如下语法: grep 'word1\|word2\|word3' /path/to/file -In this example, search warning, error, and critical words in a text log file called /var/log/messages, enter: +下的例子中,要在一个名叫 /var/log/messages 的文本日志文件中查找 warning、error 和 critical 这几个单词,输入: $ grep 'warning\|error\|critical' /var/log/messages -To just match words, add -w swith: +仅仅只是要匹配单词的话,可以加上 -w 选项参数: $ grep -w 'warning\|error\|critical' /var/log/messages -egrep command can skip the above syntax and use the following syntax: +egrep 命令可以跳过上面的语法格式,其使用的语法格式如下: $ egrep -w 'warning|error|critical' /var/log/messages -I recommend that you pass the -i (ignore case) and --color option as follows: +我建义您们加上 -i (忽略大小写) 和 --color 选项参数,如下示: $ egrep -wi --color 'warning|error|critical' /var/log/messages -Sample outputs: +输出示例: ![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 Command Search Multiple Words Demo Output +Fig.01: Linux / Unix egrep 命令查找多个单词输出例子 --------------------------------------------------------------------------------