![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| AWK - conditional cause | Rafael.Buria | Shell Programming and Scripting | 2 | 01-28-2008 01:24 PM |
| Else in If Statements | chapmana | UNIX for Dummies Questions & Answers | 8 | 11-30-2006 08:07 AM |
| Conditional Statements | cstovall | Shell Programming and Scripting | 1 | 05-15-2005 06:58 PM |
| or statements? | Blip | Shell Programming and Scripting | 1 | 01-19-2004 04:08 PM |
| if statements | lilas | UNIX for Dummies Questions & Answers | 2 | 03-22-2001 11:49 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
for i loop with conditional statements?
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...
Code:
#!/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
Code:
find /apps/migrate/output/rtdata/$i/Downloaded -type f -name "PB*" | while read CHECKFILE
do
if test -f "$CHECKFILE"
then
whatever
fi
done
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|