Linux 如何使用 rm 和 exclude 开关

Mat*_*ija 3 linux ubuntu rm switch-statement

我想知道我们如何使用带有--exclude 开关的linux rm命令?

例如,在搜索文件时,grep具有排除功能。

Mat*_*ija 5

这是一个具体的

rm `find . -name "safe_room*" ! -name "safe_rooms.php"`
Run Code Online (Sandbox Code Playgroud)

我主要将它用于 git

git rm `find . -name "safe_room*" ! -name "safe_rooms.php"`
Run Code Online (Sandbox Code Playgroud)

解释:

rm - 用于删除的 linux 命令

`` - 在 mysql 中使用的标志。在键盘上 CTRL + 7

find . -name "safe_room*" - 使用 safe_room* 查找所有内容

! - 非逻辑运算符

-name "safe_rooms.php" - 排除除了 safe_rooms.php 之外的所有内容

希望这会有所帮助:)