New to scripting in general, so patience plz. If I ask a stupid question or don't get it, I thank you for your kindness in advance.
That said, did a for i loops checks to see if a PB* file is there but I need to know two things before I copy the file.
I need to know if the file's create date is = to today and I also need to make sure I haven't copied it into the directory already. If I've already copied in the directory no need to copy it there again etc?
#!/bin/bash
oklist=`cat /export/home/jay01/scripts/oklist.txt`
for i in $oklist;
do
CHECKFILE="$(find /apps/migrate/output/rtdata/$i/Downloaded/ -name PB*)"
if [ -n "${CHECKFILE}" ]
then
echo ""
echo `date`
ls -ltr /apps/migrate/output/tdata/$i/Downloaded/
echo ""
cp -p /apps/migrate/output/tdata/$i/Downloaded/* /apps/migrate/usops/okdownload/
else
echo ""
echo " No Files to move in /apps/migrate/output/tdata/`echo $i`/Downloaded/ "
echo ""
fi
done;
I'm reposting it reformatted so it's easier to understand...
#!/bin/bash
oklist=`cat /export/home/jay01/scripts/oklist.txt`
for i in $oklist
do
CHECKFILE="$(find /apps/migrate/output/rtdata/$i/Downloaded/ -name PB*)"
if [ -n "${CHECKFILE}" ]
then
echo "***************************************************************"
echo `date`
ls -ltr /apps/migrate/output/tdata/$i/Downloaded/
echo "***************************************************************"
cp -p /apps/migrate/output/tdata/$i/Downloaded/* /apps/migrate/usops/okdownload/
else
echo "***************************************************************"
echo " No Files to move in /apps/migrate/output/tdata/`echo $i`/Downloaded/ "
echo "***************************************************************"
fi
done
now remember 'find' can return multiple answers, my general pattern with find is
find /apps/migrate/output/rtdata/$i/Downloaded -type f -name "PB*" | while read CHECKFILE
do
if test -f "$CHECKFILE"
then
whatever
fi
done