Linux如何根据文件扩展名来搜索文件

在“/home /”目录中”中搜索文件扩展名为“.sh”的文件:

$find ~/-type f | grep "\.sh$"

搜索文件扩展名.sh.txt或者.py的所有文件

$find  ~/-type f | grep -E "\.sh$|\.txt$|\.py$"

可以使用xargs对每个找到的文件执行操作,例如删除文件:

$find  ~/-type f | grep -E "\.sh$|\.txt$|\.py$" | xargs -I {} rm {} \;
日期:2020-07-07 20:56:33 来源:oir作者:oir