相关疑难解决方法(0)

从全局匹配中排除一种模式

我有几个具有相同基本文件名的文件。我想删除除一个以外的所有

foo.org #keep
foo.tex #delete
foo.fls #delete
foo.bib #delete
etc
Run Code Online (Sandbox Code Playgroud)

如果我不需要保留一个,我知道我可以使用rm foo.*.

TLDP演示^否定匹配。通过反复试验,我发现

rm foo.*[^org]
Run Code Online (Sandbox Code Playgroud)

做我需要的,但我不太了解语法。

此外,虽然在我的用例中不是限制,但我认为这种模式也忽略了foo.ofoo.or。这种模式是如何工作的,一个 忽略的 globfoo.org会是什么样子?

bash wildcards

84
推荐指数
3
解决办法
9万
查看次数

一次删除所有具有特定名称但扩展名不同的文件

我有一个目录,其中包含以下文件集:

cheatsheetold.aux
cheatsheetold.log
cheatsheetold.out
cheatsheetold.pdf
cheatsheetold.synctex.gz
cheatsheetold.tex
cheatsheetnew.aux
cheatsheetnew.log
cheatsheetnew.out
cheatsheetnew.pdf
cheatsheetnew.synctex.gz
cheatsheetnew.tex
Run Code Online (Sandbox Code Playgroud)

我想要做的是删除所有 cheetsheetold.

cheatsheetold.aux
cheatsheetold.log
cheatsheetold.out
cheatsheetold.pdf
cheatsheetold.synctex.gz
cheatsheetold.tex
Run Code Online (Sandbox Code Playgroud)

不接触 cheatsheetnew

cheatsheetnew.aux
cheatsheetnew.log
cheatsheetnew.out
cheatsheetnew.pdf
cheatsheetnew.synctex.gz
cheatsheetnew.tex
Run Code Online (Sandbox Code Playgroud)

我已经看过this other question,但它没有解决问题,因为这两个文件名都有一套完整的扩展名

terminal delete macos

5
推荐指数
2
解决办法
1247
查看次数

标签 统计

bash ×1

delete ×1

macos ×1

terminal ×1

wildcards ×1