linux文件操作

查找某一后缀的文件并作统计
find <path> -type f -name <file> | wc -l
eg:find . type f -name "*.cpp" | wc -lcov

 

查找某一后缀的文件并拷贝到某一路径
find <path> -name <file> -exec cp {} <path> \;
eg:find ../foo -name "*.cpp" -exec cp {} ./foo \;

cp `find <path> -name <file>` <path>
eg:cp `find ../foo -name *.cpp` ./foo

 

删除除某个文件之外的全部文件
rm -rf `ls | grep -v <file>`
eg:rm -rf `ls | grep -v foo.cpp`,注意是“`”不是单引号“'”

posted @ 2016-04-06 20:20  Memset  阅读(213)  评论(0编辑  收藏  举报