Hi,
I have to transfer five files from one directory to another directory in unix with the help of shell scripts. This shell script calling the param file as input parameter. Every day one file will come and fall on my source directory. Remaining files will fall on any one of the day of the month. My existing script will transfer on every day. Proposed system will transfer the file on cyclic base (whenever the four files fall on my source directory). I can't specify the those four files name on my script because this script for generic purpose. I am giving the sample data of my param file below
Do you mean that until all four files are present, you don't want to copy them?
Do they get deleted after copy (which means you really want to move them) or does the script need to distinguish which four files belong together by some other means?
Please explain what the fields mean in your "param file" and whether the "param file" is supplied or derived?
If you were to do the job manually without a script, what would you type?
infile ---> input file which contains the list of files to check.
indir ----> directory where the file comes in
newdir --> directory where the file needs to be transfered
Put the below script dirtransfer.ksh in the cron and set to check every 1 hour, everyday.
# more infile
N1.filename1
N1.filename2
N1.filename3
N1.filename4
N.dailyfile
#
#
# more dirtransfer.ksh
#!/bin/ksh
set -x
DIRNAME='indir'
NEWDIRNAME='newdir'
count=0
while read line
do
if [ -f $DIRNAME/$line ]
then
count=`expr $count + 1`
fi
done < infile
if [ $count -eq 5 ]
then
mv $DIRNAME/* $NEWDIRNAME
fi