我有几个具有相同基本文件名的文件。我想删除除一个以外的所有
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.o
和foo.or
。这种模式是如何工作的,一个只 忽略的 globfoo.org
会是什么样子?
我有一个目录,其中包含以下文件集:
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,但它没有解决问题,因为这两个文件名都有一套完整的扩展名