continue
This commit is contained in:
parent
fa6b11463e
commit
d15d4d9b86
@ -55,4 +55,38 @@ ls a[^b].txt
|
|||||||
```bash
|
```bash
|
||||||
ls a{a,b,c,d,ee}.txt
|
ls a{a,b,c,d,ee}.txt
|
||||||
```
|
```
|
||||||

|

|
||||||
|
可以看到是匹配所有的模式, 而不是其中任意一个
|
||||||
|
使用ls会提示无法找到该文件
|
||||||
|
而使用echo会直接输出这些模式的匹配结果
|
||||||
|

|
||||||
|
|
||||||
|
```bash
|
||||||
|
# 大括号可以进行嵌套
|
||||||
|
echo {j{p,pe}g,png}
|
||||||
|
# jpg jpeg png
|
||||||
|
```
|
||||||
|
|
||||||
|
{...}与[...]有一个很重要的区别。如果匹配的文件不存在,[...]会失去模式的功能,变成一个单纯的字符串,而{...}依然可以展开。
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# 不存在 a.txt 和 b.txt
|
||||||
|
ls [ab].txt
|
||||||
|
# ls: [ab].txt: No such file or directory
|
||||||
|
|
||||||
|
ls {a,b}.txt
|
||||||
|
# ls: a.txt: No such file or directory
|
||||||
|
# ls: b.txt: No such file or directory
|
||||||
|
```
|
||||||
|
|
||||||
|
### {start..end} 模式
|
||||||
|
匹配连续范围的所有情况 ( 注意中间是两个点 )
|
||||||
|
比如
|
||||||
|
```bash
|
||||||
|
# 匹配a.txt b.txt c.txt
|
||||||
|
ls {a..c}.txt
|
||||||
|
|
||||||
|
# 对于整数有特殊处理
|
||||||
|
echo {10..20}
|
||||||
|
# 输出从10到20的所有整数
|
||||||
|
```
|
||||||
Loading…
x
Reference in New Issue
Block a user