2
我有一個文件夾包含日誌文件,所有這些文件名都遵循相同的模式,唯一的變化是例如的日期:Sample_file_20131108.txt
我有一個bash腳本需要年,月和日期作爲輸入並處理在該特定日期生成的文件。使用特定的一組文件
對於例如./myscript.sh 2011
將處理在2011年./myscript.sh 201108
將處理在2011年一年中的第8個月產生的我也可以指定一個特定的日期,以及文件生成的所有腳本。這是我卡住的地方,我希望能夠指定一個月的18-25的日期。我試過這個作爲輸入myscript.sh 201108{12..25}
,但沒有奏效。所以我想弄清楚如何將它加入腳本。
這裏是我
if [ $# -ne 1 ]
then
echo $#
exit 1
fi
month=$1
#2. Find files of the month to process
LISTFILES=$TEMPDIR/listfiles.txt.$$
echo ''
echo '#2. Finding the files to process'
for i in `find . -name "sample_file*$month*.txt"`
do
echo $i >> $LISTFILES
done
echo 'done'