10
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Brace Expansionが便利

Posted at

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

$ 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}
10
6
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
10
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?