如何递归删除具有不同扩展名的多个文件? [英] How to recursively delete multiple files with different extensions?

查看:172
本文介绍了如何递归删除具有不同扩展名的多个文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图编写一个命令,从当前目录及其所有相关的子目录递归地删除具有不同扩展名(* .extension1,* .extension2等)的几个文件。

I am trying to write a command to remove recursively several files with different extensions (*.extension1, *.extension2 etc) from the current directory and all its related sub-directories.

到目前为止,我从,但我不能锻炼如何适应它在同一命令行中的多个文件:

So far I got this command from another post but I couldn't workout how to adapt it to more than one file in the same command line:

find . -name "*.extension1" -type f -delete

是否如下简单? p>

Is it as simple as below?

find . -name "*.extension1";"*.extension2" -type f -delete

这些都是我不需要的输出文件,但并不是所有输出文件都必须始终输出,因此有些扩展名可能不存在。这只是一个普通的清理命令。

Just as a side note, these are all output files that I do not need, but not all are necessarily always output so some of the extensions might not be present. This is just as a general clean-up command.

推荐答案

find . \( -name "*.extension1" -o -name "*.extension2" \) -type f -delete

find文件(-name .py-o -name .html)--exec文件{} \;

find Documents ( -name ".py" -o -name ".html" ) -exec file {} \;

OR

find . -regextype posix-egrep -regex ".*\.(extension1|extension2)$" -type f -delete

这篇关于如何递归删除具有不同扩展名的多个文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆