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

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

More than 3 years have passed since last update.

メモメモ程度に。。。

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$ 
bft
人とシステムをつくる会社
http://www.bfts.co.jp/
Why not register and get more from Qiita?
  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