Help us understand the problem. What is going on with this article?

Brace Expansionが便利

More than 5 years have passed since last update.

{}を使うと複合的な連番だったり,部分的に異なる文字列なんかを簡単に生成できます.

$ echo {a..f}{1..9}
a1 a2 a3 a4 a5 a6 a7 a8 a9 b1 b2 b3 b4 b5 b6 b7 b8 b9 c1 c2 c3 c4 c5 c6 c7 c8 c9 d1 d2 d3 d4 d5 d6 d7 d8 d9 e1 e2 e3 e4 e5 e6 e7 e8 e9 f1 f2 f3 f4 f5 f6 f7 f8 f9

$ echo hoge{,5,10}
hoge hoge5 hoge10

# 入れ子もおーけー
$ echo hoge{,_{a,b{,c,d}}}
hoge hoge_a hoge_b hoge_bc hoge_bd

for文で連番つくるときにしか使ったことありませんでしたが,ファイル,ディレクトリ名なんかをうまくこいつで指定してやれば,パスが長かったりで面倒なときにいろいろ楽できそうです.

$ cp hoge{,old}
$ mkdir /home/web/{css,js,img}
Why do not you register as a user and use Qiita more conveniently?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away