【Linux】shell脚本中的大括号{}的用法——完善中

shell脚本中的大括号{}的用法——完善中

用法1:

大括号拓展。(通配(globbing))将对大括号中的文件名做扩展。在大括号中,不允许有空白,除非这个空白被引用或转义。第一种:对大括号中的以逗号分割的文件列表进行拓展。如 touch {a,b}.txt 结果为a.txt b.txt。第二种:对大括号中以点点(…)分割的顺序文件列表起拓展作用,如:touch {a…d}.txt 结果为a.txt b.txt c.txt d.txt

# ls {ex1,ex2}.sh  
ex1.sh  ex2.sh  
# ls {ex{1..3},ex4}.sh  
ex1.sh  ex2.sh  ex3.sh  ex4.sh  
# ls {ex[1-3],ex4}.sh  
ex1.sh  ex2.sh  ex3.sh  ex4.sh

参考链接:

发布了97 篇原创文章 · 获赞 55 · 访问量 13万+

猜你喜欢

转载自blog.csdn.net/voidfaceless/article/details/103355860
今日推荐