这是我的文件夹结构:
/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
Run Code Online (Sandbox Code Playgroud)
但我想做这样的事情:
find /var/www/html -type d -name myFolder -exec find {} -name "*.php" -exec do_some_housekeeping {} \; \;
Run Code Online (Sandbox Code Playgroud)
Har*_*non 37
您可以使用该-path
选项代替-name
.它将整个绝对路径与正则表达式匹配.
find /var/www/html -path "*/myFolder/*.php" -exec do_some_housekeeping {} \;
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
37987 次 |
最近记录: |