Chinaunix

标题: 请教:find命令如何查找指定目录下的全部C和C++文件 [打印本页]

作者: hzy2hzy    时间: 2015-09-23 16:16
标题: 请教:find命令如何查找指定目录下的全部C和C++文件
find /home/user -name "*.c|*.cpp"不能用

作者: songyc_2015    时间: 2015-09-23 16:19
find /home/user -name "*.c" -o -name "*.cpp"
作者: MMMIX    时间: 2015-09-23 17:11
回复 1# hzy2hzy


    工具不会用要看文档,不能想当然。
作者: csoho2000    时间: 2015-09-23 17:31
本帖最后由 csoho2000 于 2015-09-23 17:32 编辑
songyc_2015 发表于 2015-09-23 16:19
find /home/user -name "*.c" -o -name "*.cpp"


再次升级
find /home/user -name "*.c" -o -name "*.cpp" -exec cp -rf {} /root/ \;
将找到的内容拷贝到/root下
作者: tuyajie    时间: 2015-09-23 22:28
[jay.liu@aliCloud ~]$ find ./ -name "*cpp" -o -name "*.c"
./1.cpp
./1.c
[jay.liu@aliCloud ~]$ ls
1.c  1.cpp  2  chinaUnix  private  test.sh  transit
作者: 聆雨淋夜    时间: 2015-09-24 23:04
find: 合法的类型是 “findutils-default”, “awk”, “egrep”, “ed”, “emacs”, “gnu-awk”, “grep”, “posix-awk”, “posix-basic”, “posix-egrep”, “posix-extended”, “posix-minimal-basic”, “sed”。

find ./ -regextype "egrep" -regex ".*\.c|.*\.cpp"





欢迎光临 Chinaunix (http://bbs.chinaunix.net/) Powered by Discuz! X3.2