您的位置:首页 > 运维架构 > Linux

linux文件操作

2016-04-06 20:20 330 查看

查找某一后缀的文件并作统计
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`,注意是“`”不是单引号“'”

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: