jor*_*lli 14
使用find
命令。
Find all files (recursively) matching a regex: find . -type f -regex '/ex/'
Find all files (recursively) matching a regex and delete them:find . -type f -regex '/ex/' -exec rm {} \;
方括号存储找到的路径名,反斜杠转义分号,因为它被传递给 find;如果不逃脱它,它将被外壳消耗掉。如果这超出了您的理解,请阅读“学习 Bash Shell”的前两章。
查看手册页以find
获取更多选项。还有更多的搜索方式。