mirror of
https://github.com/LCTT/TranslateProject.git
synced 2025-02-25 00:50:15 +08:00
PUB:20151127 Linux or UNIX grep Command Tutorial series 4--Grep Count Lines If a String or Word Matches
@runningwater
This commit is contained in:
parent
9f36a2ebdf
commit
2343b8358a
@ -1,8 +1,9 @@
|
|||||||
Grep 命令统计匹配的字符串/单词行数
|
grep 命令系列:用 grep 命令统计匹配字符串的行数
|
||||||
================================================================================
|
================================================================================
|
||||||
|
|
||||||
在 Linux 或 UNIX 操作系统下,对于给定的单词或字符串,我们应该怎么统计它们在每个输入文件中存在的行数呢?
|
在 Linux 或 UNIX 操作系统下,对于给定的单词或字符串,我们应该怎么统计它们在每个输入文件中存在的行数呢?
|
||||||
|
|
||||||
您需要通过添加 -c 或者 --count 选项参数来抑制正常的输出。它将会显示对输入文件单词匹配的行数,如下示:
|
您需要通过添加 -c 或者 --count 选项参数来抑制正常的输出。它将会显示对输入文件单词匹配的行数,如下所示:
|
||||||
|
|
||||||
$ grep -c vivek /etc/passwd
|
$ grep -c vivek /etc/passwd
|
||||||
|
|
||||||
@ -28,6 +29,6 @@ via: http://www.cyberciti.biz/faq/grep-count-lines-if-a-string-word-matches/
|
|||||||
|
|
||||||
作者:Vivek Gite
|
作者:Vivek Gite
|
||||||
译者:[runningwater](https://github.com/runningwater)
|
译者:[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/) 荣誉推出
|
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
Loading…
Reference in New Issue
Block a user