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

/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 {} \;

相关文章

insmod和modprobe加-f参数导致Invalid module format错误 这...
将ArchLinux安装到U盘 几个月前入门Arch的时候上网搜了不少安...
1、安装Apache。 1)执行如下命令,安装Apache服务及其扩展包...
一、先说一下用ansible批量采集机器信息的实现办法: 1、先把...
安装配置 1. 安装vsftpd 检查是否安装了vsftpd # rpm -qa | ...
如何抑制stable_secret读取关键的“net.ipv6.conf.all.stabl...