Just a quick query does that work on the datestamp of the file and not the actual date format in the file name, I have created the copies of these files from one server to the other so the datestamp will be the same on all of them
awk 'BEGIN {
## you do the maths...this may not be correct. calculate how many secs in 7 days
onehr=60
onemin=60
oneday = ( onehr * onemin ) * 24
sevendays = oneday * 7
}
day=substr($0,3,2)
month=substr($0,5,2)
year=substr($0,7,2)
hr=substr($0,9,2)
min=substr($0,11,2)
t="20"year" "month" "day" "hr" "min" "00
d=mktime(t)
now=systime()
if ( ( now - d ) >= sevendays ) {
print $0
}
}' file
#!/bin/ksh
GetDate()
{
# Exemple: GetDate -1 '+%Y%m%d'
typeset -i nDays=$1; format=$2
eval $(echo $TZ | sed '
s!\([^-0-9]*\)\([-0-9]*\)\(.*\)!typeset -i localOffset=\2;zon1=\1;zon2=\3!')
TZ=$zon1$((localOffset-24*nDays))$zon2 date $format
}
liste=$(ls dd*.txt)
ndate=$(GetDate -7 '+%y%m%d')
for i in $liste
do
# Get the file date in YYMMDD format
ydate=$(echo $i | cut -c7-8)
mdate=$(echo $i | cut -c5-6)
ddate=$(echo $i | cut -c3-4)
zdate=${ydate}${mdate}${ddate}
if [ $zdate -lt $ndate ]
then
echo "$i: file to move"
else
echo "$i: do not move"
fi
done