From f73f698f171617cbc4b86513e2b2743ce0774959 Mon Sep 17 00:00:00 2001 From: runningwater Date: Fri, 8 Jan 2016 10:02:20 +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 --- ...rep Count Lines If a String or Word Matches.md | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) rename {sources => translated}/tech/Linux or UNIX grep Command Tutorial series/20151127 Linux or UNIX grep Command Tutorial series 4--Grep Count Lines If a String or Word Matches.md (55%) diff --git a/sources/tech/Linux or UNIX grep Command Tutorial series/20151127 Linux or UNIX grep Command Tutorial series 4--Grep Count Lines If a String or Word Matches.md b/translated/tech/Linux or UNIX grep Command Tutorial series/20151127 Linux or UNIX grep Command Tutorial series 4--Grep Count Lines If a String or Word Matches.md similarity index 55% rename from sources/tech/Linux or UNIX grep Command Tutorial series/20151127 Linux or UNIX grep Command Tutorial series 4--Grep Count Lines If a String or Word Matches.md rename to translated/tech/Linux or UNIX grep Command Tutorial series/20151127 Linux or UNIX grep Command Tutorial series 4--Grep Count Lines If a String or Word Matches.md index c145320e5a..63cb1aa189 100644 --- a/sources/tech/Linux or UNIX grep Command Tutorial series/20151127 Linux or UNIX grep Command Tutorial series 4--Grep Count Lines If a String or Word Matches.md +++ b/translated/tech/Linux or UNIX grep Command Tutorial series/20151127 Linux or UNIX grep Command Tutorial series 4--Grep Count Lines If a String or Word Matches.md @@ -1,25 +1,24 @@ -(translating by runningwater) -Grep Count Lines If a String / Word Matches +Grep 命令统计匹配的字符串/单词行数 ================================================================================ -How do I count lines if given word or string matches for each input file under Linux or UNIX operating systems? +在 Linux 或 UNIX 操作系统下,对于给定的单词或字符串,我们应该怎么统计它们在每个输入文件中存在的行数呢? -You need to pass the -c or --count option to suppress normal output. It will display a count of matching lines for each input file: +您需要通过添加 -c 或者 --count 选项参数来抑制正常的输出。它将会显示对输入文件单词匹配的行数,如下示: $ grep -c vivek /etc/passwd -OR +或者 $ grep -w -c vivek /etc/passwd -Sample outputs: +输出的示例: 1 -However, with the -v or --invert-match option it will count non-matching lines, enter: +相反的,使用 -v 或者 --invert 选项参数可以统计出不匹配的输入文件行数,键入: $ grep -c vivek /etc/passwd -Sample outputs: +输出的示例: 45