27
15

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.

linuxで連番のディレクトリを一括で作る方法

Last updated at Posted at 2018-06-25

画像格納やらキャッシュやらで、0から99までの100個のディレクトリを作りたいってことが稀にある。
コマンドひとつで解決したのでメモ。

環境

  • bash 4.1.2

コマンド

0から99まで一括でディレクトリ作る

$ mkdir {0..99}

確認

$ ls
0   18  27  36  45  54  63  72  81  90
1   19  28  37  46  55  64  73  82  91
10  2   29  38  47  56  65  74  83  92
11  20  3   39  48  57  66  75  84  93
12  21  30  4   49  58  67  76  85  94
13  22  31  40  5   59  68  77  86  95
14  23  32  41  50  6   69  78  87  96
15  24  33  42  51  60  7   79  88  97
16  25  34  43  52  61  70  8   89  98
17  26  35  44  53  62  71  80  9   99

できてるー!

一桁の場合に左を0で詰めて欲しい場合はこんなんでいける

$ mkdir {00..99}

確認

$ ls
00  10  20  30  40  50  60  70  80  90
01  11  21  31  41  51  61  71  81  91
02  12  22  32  42  52  62  72  82  92
03  13  23  33  43  53  63  73  83  93
04  14  24  34  44  54  64  74  84  94
05  15  25  35  45  55  65  75  85  95
06  16  26  36  46  56  66  76  86  96
07  17  27  37  47  57  67  77  87  97
08  18  28  38  48  58  68  78  88  98
09  19  29  39  49  59  69  79  89  99

できてるー!

アルファベット順に作りたいときは、こんなん

$ mkdir {a..z}
$ ls
a  c  e  g  i  k  m  o  q  s  u  w  y
b  d  f  h  j  l  n  p  r  t  v  x  z

ひとつかしこくなりました。

27
15
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
27
15

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?