I have list of filename which have format like this _ddmmyyyy.txt for example :
filea_01122016.txt
filea_02122016.txt
filea_03122016.txt
filea_04122016.txt
filea_05122016.txt
And I want to compress those file from sysdate - 3 days in my RHEL environment. Assume today is 5 Dec 2016 and I want compress those file start from date 2 dec, 1 dec backward. Because the date that Im using is from the file name not the timestamp of file created(by system).
I read some tutorial that they are using find
utility but in my case Im using date from the filename.
I already make some mechanism like this for compressing text in a whole month
dir=`date '+%Y%m%d'`
tanggal=`date --date="$(date +%Y-%m-15) -1 month" '+%Y%m'`
base=/inf_shr/ProcessedSrc/CDC/ARCHIVE/F_ABC
cd $base
mkdir $dir
cp ../../F_CC/*${tanggal}* $dir
tar cvf - $dir | gzip -9 - > ${tanggal}_F_CC.tar.gz
rm -rf $dir
rm -rf ../../F_CC/*${tanggal}*
Now I want compress for file with sysdate - 3 days *)sorry for my english
And idea for the code? thank you
TL;DR but below would be my approach