![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | 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 here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Moving files not directory. | senthil_is | Shell Programming and Scripting | 1 | 05-08-2008 10:21 PM |
| Mutiple For loops - moving files to another directory | tekster757 | Shell Programming and Scripting | 9 | 06-21-2007 05:42 AM |
| How to Compress files before moving them in a directory | godalle | Shell Programming and Scripting | 3 | 11-10-2005 08:59 AM |
| moving files from a unix directory to a windows directory | gleads | UNIX for Dummies Questions & Answers | 2 | 08-29-2002 05:42 PM |
| Suppres error message when moving files from empty source folder | Steven | Shell Programming and Scripting | 2 | 11-19-2001 10:25 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Getting unusual error - moving files to another directory
Dear experts,
Im having an unusual problem and its been giving me a bad headache. I have the script below Code:
#!/usr/bin/sh -x ticketinputdir=/IN_DATA1/tickets ticketoutputdir=/IN_DATA2 YDAY=`env TZ=A12B date '+%Y%m%d'` for i in INA INB INC IND INE do mkdir $ticketoutputdir/$i/$YDAY files2mv=`ls $ticketinputdir | grep StatData$i | grep $YDAY` chmod 777 $ticketoutputdir/$i/$YDAY /usr/bin/mv $files2mv $ticketoutputdir/$i/$YDAY done Quote:
|
| Forum Sponsor | ||
|
|
|
#2
|
||||
|
||||
|
Hi,
how about adding another for loop instead of "mv'ing" them in one go: Code:
#!/usr/bin/sh -x
ticketinputdir=/IN_DATA1/tickets
ticketoutputdir=/IN_DATA2
YDAY=`env TZ=A12B date '+%Y%m%d'`
for i in INA INB INC IND INE
do
mkdir -p $ticketoutputdir/$i/$YDAY
files2mv=`ls $ticketinputdir | grep StatData$i | grep $YDAY`
for j in $files2mv
do
mv $j $ticketoutputdir/$i/$YDAY && echo $j moved to $ticketoutputdir/$i/$YDAY
done
done
|
|
#3
|
|||
|
|||
|
Hi andryk,
I tried the method you adviced above. I'm still getting the following errors. Ivae changed all permissions to 777. This is really wierd. Quote:
|
|
#4
|
|||
|
|||
|
andryk, i fugured out the problem. its because when the second loop takes place, it cannot understand the full path of StatDataINE_890_cat_20071220_120900.txt.Z. Ive modified the script. Thanks !!!
|
|
#5
|
||||
|
||||
|
Code:
#!/usr/bin/sh -x
ticketinputdir=/IN_DATA1/tickets
ticketoutputdir=/IN_DATA2
YDAY=`env TZ=A12B date '+%Y%m%d'`
for i in INA INB INC IND INE
do
mkdir -p $ticketoutputdir/$i/$YDAY
files2mv=`ls $ticketinputdir | grep StatData$i | grep $YDAY`
for j in $files2mv
do
mv $ticketinputdir/$j $ticketoutputdir/$i/$YDAY && echo $j moved to $ticketoutputdir/$i/$YDAY
done
done
|
||||
| Google The UNIX and Linux Forums |