如何在字符类中排除字符?

时间:2023-01-07 07:31:31

How do I combine the following lines for one character:

我如何将以下几行组合成一个字符:

> ls file[1-5]
> ls file[!3]

To produce the same result as:

产生如下结果:

> ls file[1-2,4-5] 
> file1 file2 file4 file5

2 个解决方案

#1


2  

The right syntax with the range is

使用范围的正确语法是

ls file{[1-2],[4-5]}

#2


0  

It will certainly vary with the context. In zsh, you can do:

它肯定会随上下文而变化。在zsh,你可以:

$ set -o EXTENDED_GLOB
$ ls file([1-5]~3)

#1


2  

The right syntax with the range is

使用范围的正确语法是

ls file{[1-2],[4-5]}

#2


0  

It will certainly vary with the context. In zsh, you can do:

它肯定会随上下文而变化。在zsh,你可以:

$ set -o EXTENDED_GLOB
$ ls file([1-5]~3)