LoginSignup
4
4

More than 5 years have passed since last update.

テストファイル作るときに楽したい

Posted at

メモメモ程度に。。。

make_testfile.sh
#!/bin/bash
#
# Creating test file
#
# make_testfile.sh
#
############################################

INFILE="./INFILE.txt"
# INFILEは YYYYMMDD 形式
DIR=""
TIME="1200"

while read line; do
    DT=`echo $line | awk '{print substr($0, 5)}'`
    touch -t ${DT}${TIME} ${DIR}${line}.txt
done < ${INFILE}

echo Success!!
exit
INFILE.txt
20160101
20160102
20160103
20160104
20160105
20160106
20160107
20160108
20160109
20160110
20160111
20160112
20160113
20160114
20160115
20160116
20160117
20160118
20160119
20160120
20160121

こんな感じ。

MacBookAir:test user$ ll
total 0
-rw-r--r--  1 user  staff  0  1  1  2016 20160101.txt
-rw-r--r--  1 user  staff  0  1  2  2016 20160102.txt
-rw-r--r--  1 user  staff  0  1  3  2016 20160103.txt
-rw-r--r--  1 user  staff  0  1  4  2016 20160104.txt
-rw-r--r--  1 user  staff  0  1  5  2016 20160105.txt
-rw-r--r--  1 user  staff  0  1  6  2016 20160106.txt
-rw-r--r--  1 user  staff  0  1  7  2016 20160107.txt
-rw-r--r--  1 user  staff  0  1  8  2016 20160108.txt
-rw-r--r--  1 user  staff  0  1  9  2016 20160109.txt
-rw-r--r--  1 user  staff  0  1 10  2016 20160110.txt
-rw-r--r--  1 user  staff  0  1 11  2016 20160111.txt
-rw-r--r--  1 user  staff  0  1 12  2016 20160112.txt
-rw-r--r--  1 user  staff  0  1 13  2016 20160113.txt
-rw-r--r--  1 user  staff  0  1 14  2016 20160114.txt
-rw-r--r--  1 user  staff  0  1 15  2016 20160115.txt
-rw-r--r--  1 user  staff  0  1 16  2016 20160116.txt
-rw-r--r--  1 user  staff  0  1 17  2016 20160117.txt
-rw-r--r--  1 user  staff  0  1 18  2016 20160118.txt
-rw-r--r--  1 user  staff  0  1 19  2016 20160119.txt
-rw-r--r--  1 user  staff  0  1 20  2016 20160120.txt
-rw-r--r--  1 user  staff  0  1 21  2016 20160121.txt
MacBookAir:test user$ 
4
4
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
4
4