除了一些RM的所有文件

编程入门 行业动态 更新时间:2024-10-28 06:30:59
本文介绍了除了一些RM的所有文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

在使用 sudo的RM -r ,我怎么可以删除所有文件,但下列除外:

TextFile.txt的backup.tar.gzscript.php的database.sql信息.txt

解决方案

找到[路径]型的F - 不是-name'EXPR'-print0 | xargs的-0的RM -

例如,删除当前目录中的所有非TXT的文件:

找到。型的F - 不是-name'* TXT'-print0 | xargs的-0的RM -

查找| xargs的组合是非常有用的。

如果你不指定型F找到也将列出目录,你可能不希望。

When using sudo rm -r, how can I delete all files, with the exception of the following:

textfile.txt backup.tar.gz script.php database.sql info.txt

解决方案

find [path] -type f -not -name 'EXPR' -print0 | xargs -0 rm --

for example, delete all non txt-files in the current directory:

find . -type f -not -name '*txt' -print0 | xargs -0 rm --

The "find | xargs" combination is really useful.

If you don't specify "-type f" find will also list directories, which you may not want.

更多推荐

除了一些RM的所有文件

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

发布评论

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

>www.elefans.com

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