如何递归删除具有不同扩展名的多个文件?

编程入门 行业动态 更新时间:2024-10-26 06:31:37
本文介绍了如何递归删除具有不同扩展名的多个文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我试图编写一个命令,从当前目录及其所有相关的子目录递归地删除具有不同扩展名(* .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

更多推荐

如何递归删除具有不同扩展名的多个文件?

本文发布于:2023-11-02 17:54:09,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1553033.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:递归   多个   扩展名   文件

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!