Home > Backend Development > PHP Tutorial > linux查找关键字在php出现的次数

linux查找关键字在php出现的次数

WBOY
Release: 2016-06-23 13:28:11
Original
824 people have browsed it


查找CleverCode在当前目录以及子目录,所有的php出现大于0的次数。



# find -type f -name '*.php' | xargs grep CleverCode ./*.php -rc | awk  -F ':'  '$2 > 0 {print $1,$2}' | grep -v '/.svn/' | sort -n -k 2 -r


1)find -type f -name '*.php'。查找当前目录以及子目录中所有的php文件。
2)xargs grep CleverCode ./*.php -rc。在每个文件中查找CleverCode关键字,并显示出现次数。
3)awk  -F ':'  '$2 > 0 {print $1,$2}'。用':'分割列,显示第2列>0的行。
4)grep -v '/.svn/' 。去掉.svn目录数据
5)sort -n -k 2 -r。按照第2列数组大小降序排序。

版权声明:本文为博主原创文章,未经博主允许不得转载。

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template