You can use the date command to give you back the current date, or modify it to give you the dates you want. For example, this will give you todays date:
While this will give you yesterday:
Code:
$(date -d "-1 day" +"%Y%m%d")
If you use those in a bash script, you can do what you need. Since I am not sure of which files you do not want in the future, to start, here is something basic.
Code:
#!/bin/bash
now=$(date +"%Y%m%d")
source=/iis_data/source
destination=/iis_data/destination
previous=`cat new_file | grep -o $now_Employee.txt`
if [ -z $previous ]
thenmv $source/$now_Employee.txt $destination/$now_Employee.txt
echo $source/$now_Employee >> new_file
elseecho "This has already been done"
fi
This will work for todays date only, but can be modified to what you need to do.
EDIT:
To loop through the last 30 days, add in a for loop:
Code:
for (( x=0 ; x < 30 ; x++ ))
do
d=`date -d "-$x day ago" +%Y-%m-%d`
#do the above here in place of now
mv $source/$d_Employee.txt $destination/$d_Employee.txt
done