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)
 

相关文章:

  • 2021-05-02
  • 2022-03-01
  • 2021-10-26
  • 2021-07-04
  • 2022-12-23
  • 2022-01-14
猜你喜欢
  • 2022-01-08
  • 2022-12-23
  • 2021-07-09
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-09-06
相关资源
相似解决方案