LoginSignup
6
6

More than 5 years have passed since last update.

forとseqで連番ファイル操作

Last updated at Posted at 2013-07-12
for i in `seq -w 1 31`;do touch 2013.07.$i.txt;done

seqコマンドにwオプションを付けることで足りない桁を0埋めしてくれることを利用して日付形式のファイル名を操作するときによく使います。

実行結果
$ for i in `seq -w 1 31`;do touch test.2013.07.$i.txt;done
$ ll
total 0
-rw-r--r--  1 okisanjp  staff    0  7 13 07:52 test.2013.07.01.txt
-rw-r--r--  1 okisanjp  staff    0  7 13 07:52 test.2013.07.02.txt
-rw-r--r--  1 okisanjp  staff    0  7 13 07:52 test.2013.07.03.txt
-rw-r--r--  1 okisanjp  staff    0  7 13 07:52 test.2013.07.04.txt
-rw-r--r--  1 okisanjp  staff    0  7 13 07:52 test.2013.07.05.txt
-rw-r--r--  1 okisanjp  staff    0  7 13 07:52 test.2013.07.06.txt
-rw-r--r--  1 okisanjp  staff    0  7 13 07:52 test.2013.07.07.txt
-rw-r--r--  1 okisanjp  staff    0  7 13 07:52 test.2013.07.08.txt
-rw-r--r--  1 okisanjp  staff    0  7 13 07:52 test.2013.07.09.txt
-rw-r--r--  1 okisanjp  staff    0  7 13 07:52 test.2013.07.10.txt
-rw-r--r--  1 okisanjp  staff    0  7 13 07:52 test.2013.07.11.txt
-rw-r--r--  1 okisanjp  staff    0  7 13 07:52 test.2013.07.12.txt
-rw-r--r--  1 okisanjp  staff    0  7 13 07:52 test.2013.07.13.txt
-rw-r--r--  1 okisanjp  staff    0  7 13 07:52 test.2013.07.14.txt
-rw-r--r--  1 okisanjp  staff    0  7 13 07:52 test.2013.07.15.txt
-rw-r--r--  1 okisanjp  staff    0  7 13 07:52 test.2013.07.16.txt
-rw-r--r--  1 okisanjp  staff    0  7 13 07:52 test.2013.07.17.txt
-rw-r--r--  1 okisanjp  staff    0  7 13 07:52 test.2013.07.18.txt
-rw-r--r--  1 okisanjp  staff    0  7 13 07:52 test.2013.07.19.txt
-rw-r--r--  1 okisanjp  staff    0  7 13 07:52 test.2013.07.20.txt
-rw-r--r--  1 okisanjp  staff    0  7 13 07:52 test.2013.07.21.txt
-rw-r--r--  1 okisanjp  staff    0  7 13 07:52 test.2013.07.22.txt
-rw-r--r--  1 okisanjp  staff    0  7 13 07:52 test.2013.07.23.txt
-rw-r--r--  1 okisanjp  staff    0  7 13 07:52 test.2013.07.24.txt
-rw-r--r--  1 okisanjp  staff    0  7 13 07:52 test.2013.07.25.txt
-rw-r--r--  1 okisanjp  staff    0  7 13 07:52 test.2013.07.26.txt
-rw-r--r--  1 okisanjp  staff    0  7 13 07:52 test.2013.07.27.txt
-rw-r--r--  1 okisanjp  staff    0  7 13 07:52 test.2013.07.28.txt
-rw-r--r--  1 okisanjp  staff    0  7 13 07:52 test.2013.07.29.txt
-rw-r--r--  1 okisanjp  staff    0  7 13 07:52 test.2013.07.30.txt
-rw-r--r--  1 okisanjp  staff    0  7 13 07:52 test.2013.07.31.txt
6
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
6
6