linux如何查找具体文件在特定文件夹中
发布时间:2020-12-13 19:38:36 所属栏目:Linux 来源:网络整理
导读:这是我的文件夹结构: /site1/myFolder/otherFolder1/a.gif /site1/myFolder/otherFolder1/b.png /site1/myFolder/otherFolder1/c.php … /site2/myFolder/otherFolder2/d.gif /site2/myFolder/otherFolder2/e.png /site2/myFolder/otherFolder2/f.php … /s
这是我的文件夹结构:
/site1/myFolder/otherFolder1/a.gif /site1/myFolder/otherFolder1/b.png /site1/myFolder/otherFolder1/c.php … /site2/myFolder/otherFolder2/d.gif /site2/myFolder/otherFolder2/e.png /site2/myFolder/otherFolder2/f.php … /site3/myFolder/otherFolder3/g.gif /site3/myFolder/otherFolder3/h.png /site3/myFolder/otherFolder3/i.php … 得到这么远 find /var/www/html -type d -name myFolder -exec find {} -name "*.php" ; for i in `find /var/www/html -type d -name myFolder -exec find {} -name "*.php" ;` do some_house_keeping_here done 但是我想做这样的事情: find /var/www/html -type d -name myFolder -exec find {} -name "*.php" -exec do_some_housekeeping {} ; ; 解决方法
您可以使用-path选项而不是-name.它将匹配整个绝对路径与正则表达式.
find /var/www/html -path "*/myFolder/*.php" -exec do_some_housekeeping {} ; (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |