简体   繁体   English

Shell命令用于计算文件中的单词

[英]Shell command for counting words in files

I want to run a command, that will count the number of words in all file. 我想运行一个命令,它将计算所有文件中的单词数。 (From the selected number of files) (从选定的文件数量)

If i do like, find ABG-Development/ -name "*.php" | grep "<?" | wc -l 如果我愿意, find ABG-Development/ -name "*.php" | grep "<?" | wc -l find ABG-Development/ -name "*.php" | grep "<?" | wc -l find ABG-Development/ -name "*.php" | grep "<?" | wc -l , it will search only in the filename not the file contents. find ABG-Development/ -name "*.php" | grep "<?" | wc -l ,它只搜索文件名而不搜索文件内容。

And I tried one more way like 我尝试了另外一种方式

find ABG-Development/ -name "*.php" -exec grep "<?" {} \\; | wc -l find ABG-Development/ -name "*.php" -exec grep "<?" {} \\; | wc -l , I got error. find ABG-Development/ -name "*.php" -exec grep "<?" {} \\; | wc -l ,我收到了错误。

In above example I need how many time " 在上面的例子我需要多少时间“

Please help.. 请帮忙..

使用xargs

find ABG-Development/ -name "*.php" -print0 | xargs -0 grep "<?" | wc -l

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM