Ok, so here is what I am looking for..
Shell script that uses find to look for one days worth of data using the modified date and then copies only those files to a specified directory.
I figured I could use grep and the find command to do this. It seems to work just fine from what I can tell... However....
When the file isn't created for that day and my shell script runs (cron job) this is the error I get. I was hoping to remove that error message as I dont need to know if there isnt any files. However, I created a simple echo just to test the functionality and I am still getting an error.
Here is the script.
#!/usr/bin/ksh
#The below specifies daily RX and RS files from the T00010 Folder
#It pulls only files that are one day old
#Created by: Techjunky
file1=`find /opt/gp00/data/T00010/CYC_REPORTS -mtime 0 | egrep -i 'RX010453'`
file2=`find /opt/gp00/data/T00010/CYC_REPORTS -mtime 0 | egrep -i 'RS010453'`
#The below script copies RX and RS files within the T00010 folder if they exist
#This process is used for EC2000 Reporting for customer 10453. There is a windows scheduled task on WNP4694 to copy the files to a specified folder.
if [$file1]; then
cp $file1 /opt/gp00/data/T00010/CYC_REPORTS/10453/RX/
else
echo RX file does not exist!
if [$file2]; then
cp $file2 /opt/gp00/data/T00010/CYC_REPORTS/10453/RS/
else
echo RS file does not exist!
fi
fi
exit 1
Here is the error message I get when there aren't files for that day.
./CYC_REPORTS_10453.sh[9]: []: not found
RX file does not exist!
./CYC_REPORTS_10453.sh[13]: []: not found
RS file does not exis
t!
basically my script runs, but there is no file there so I get the error message... It makes perfect sense why I am getting that error mesage I just cant think of the logic so this wont happen. Just getting the RX and RS echo messages would be enough.
