[Bash] Curly braces tips

For example I want to override and rename file.txt_ with file.txt

mv file.txt{_,}

You can also check the full command with echo

echo mv file.txt{_,}
# > mv file.txt_ file.txt

Another example: if you want to cat beep.txt and boop.txt file, instead of doing cat beep.txt boop.txt, you can do cat b{ee,oo}p.txt.

Using {} for loop over items in collection

echo {a,b}{c,d}
# > ac ad bc bd

generate senquence string

echo img{0..10}.png

# > img0.png img1.png img2.png img3.png img4.png img5.png img6.png img7.png img8.png img9.png img10.png

You can give step as well

echo img{0..100..10}.png

# > img0.png img10.png img20.png img30.png img40.png img50.png img60.png img70.png img80.png img90.png img100.png

Example of generate directory:

mkdir -p images/img{0..10..10}.png
posted @   Zhentiw  阅读(7)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· AI技术革命,工作效率10个最佳AI工具
历史上的今天:
2023-05-15 [Rust] Collect()
2019-05-15 [Functional Programming] Week logic
2018-05-15 [Javascript] Getter and Setter Abstractions
2017-05-15 [Recompose] Flatten a Prop using Recompose
2017-05-15 [Recompose] Lock Props using Recompose -- withProps
2017-05-15 [Recompose] Transform Props using Recompose --mapProps
2017-05-15 [Recompose] Add Lifecycle Hooks to a Functional Stateless Component using Recompose
点击右上角即可分享
微信分享提示