find 进阶用法

指定深度
-H 3

查找当前目录内的文件(-type f)或文件夹(-type d),并按照原始目录结构复制到另一目录
find fromDir -iname "filename" -type d -exec cp -fr {} toDir/{} \;


类似的删除特定目录下的所有特定文件夹
find fromDir -iname "filename" -type d -exec rm -fr {} \;


列出指定目录及子目录包含特定字符串的所有文件名
find fromDir -iname "filename" -type f -exec grep "string" {} \; -print

猜你喜欢

转载自xuhuandh.iteye.com/blog/784104