渔舟唱晚的天空
——welkinwalker的遐想
find -regex .*cc -o -regex .*h | xargs wc -l

find也自带了执行命令的方法:find -regex .*cc -o -regex .*h -exec wc -l '{}' \; 

这种方法的结果不太对,只能统计到满足  -regex .*h 的文件

 

注明一下:

find默认从当前目录递归的查找;

-o 表示条件或;

-regex表示正则表达式条件;

{}使用来替换满足条件的结果的,要用’‘括起来;

-exec执行命令需要加分号;,不过要使用反斜杠转移;

也可以指定文件类型,用-type 指定,方法如下: 

-type c
File is of type c:
b
block (buffered) special
c
character (unbuffered) special
d
directory
p
named pipe (FIFO)
f
regular file
l
symbolic link
s
socket
D
door (Solaris)
 

posted on 2011-07-20 14:10  welkinwalker  阅读(506)  评论(0编辑  收藏  举报