Thanks Methyl for your reply. Pls find the answers to your queries below,
LINUX version :
2.6.18-274.el5
what Shell you use : ksh
whether you have the GNU version of the
date command and whether you have Perl installed - the date command gives me an output as below,
Fri Jun 15 08:49:28 CDT 2012
Is your range inclusive or exclusive or some combination of the two : Yes, if i pass the BUS_DATE=20120615 & SUB_DATE=20120611, it should even include files for these 2 dates as well.
Please give a simple example showing real filenames in the form of an abbreviated
ls -la listing (I hope your filenames do not actually have brackets in them).
filename is as below,
20120615_filename.dat
20120614_filename.dat etc
Very important: Does the directory timestamp on every file match the date in the name of the file?
Need not be the same. If we run the run the process that generates the file multiple times a day, the timestamp will be the same, but the date value in the file will be different.
Hope I answered your questions.
Thanks much,
Freddie
---------- Post updated at 10:26 AM ---------- Previous update was at 09:53 AM ----------
Hi Lam,
Thanks for the solution you provided. I tried running it, but it throws error msg, Here is what I tried
Quote:
PARAMFILE=/dev/tmp/DynamicDateFile.txt
DIRA=/dev/cmg/ctl/
DIRB=/dev/cmg/ctl/inbox/
SINCE=$(grep BUS_DT $PARAMFILE 2>/dev/null | egrep -o "[0-9]{8}$" 2>/dev/null)
TILL=$(grep SUB_DT $PARAMFILE 2>/dev/null | egrep -o "[0-9]{8}$" 2>/dev/null)
find $DIRA -maxdept 1 -type f | while IFS= read -r filenameA; do
FILEDATE=$(egrep -o "[0-9]{8}$" <<<$filenameA 2>/dev/null)
[[ $FILEDATE != "" ]] && (( $FILEDATE >= $SINCE )) && (( $FILEDATE <= $TILL )) && cp -t $DIRB $NOMEFILE
done
exit
Error msg :
Quote:
PARAMFILE=/dev/tmp/scripts/DynamicDateFile.txt
+ DIRA=/dev/cmg/ctl/
+ DIRB=/dev/cmg/ctl/inbox/
++ grep BUS_DT //dev/tmp/scripts/DynamicDateFile.txt
++ egrep -o '[0-9]{8}$'
+ SINCE=
++ grep SUB_DT /dev/tmp/scripts/DynamicDateFile.txt
++ egrep -o '[0-9]{8}$'
+ TILL=
+ find /dev/cmg/ctl/ -maxdept 1 -type f
+ IFS=
+ read -r filename
find: invalid predicate `-maxdept'
+ exit
Also,regarding the .done file, if I pass the BUS_DATE=20120615 & SUB_DATE=20120613,
the .done should have values as below,
20120615,20120614,20120613
Hope i answered your questions.
Thanks Much for your help,
Freddie