![]() |
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 |
| error reading sections error at install | doelman | SUN Solaris | 2 | 02-05-2007 12:21 PM |
| Error Message | chapmana | UNIX for Dummies Questions & Answers | 5 | 11-29-2006 11:41 AM |
| error message | dsmv | UNIX for Advanced & Expert Users | 4 | 03-01-2006 04:15 AM |
| Error message | ghuber | SUN Solaris | 0 | 11-13-2005 04:20 PM |
| error message | alisev | UNIX for Dummies Questions & Answers | 3 | 01-08-2002 05:01 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
cat /path/to/file/$file1 | while read a
do var1=`echo "$a"` mv /path/to/data/'$var1' /path/to/new/location if [ $? -eq 0 ] then echo "Moved File" $var1 > /path/to/file/logs/filesmoved$year$month$day.txt fi done < /path/to/file/$file1 |
|
|||||
|
very simple
mv /path/to/data/'$var1' /path/to/new/location 2>/dev/null However, it is always a good practice to log all kind of messages in your log. This can help you find if anything is messed up. I guess you must be knowing about redirection, but still since this question is related to that let me explain what exactly the 2>/dev/null do well 2 stands for the file descriptor, standard errors. so any errors that are directed to standard error are written in file descriptor 2. by doing 2> you are asking to redirect the standard errors. /dev/null is a null device. so 2>/dev/null is instructing to direct standard errors to a null device instead of the console or your error log other standard file descriptors are 0 standard output 1 standard input one more remark i feel "done < /path/to/file/$file1" is redundant, you may discard it as well since you are already doing a "cat < /path/to/file/$file1" let me make this a bit more straight, (if i havent misinterpreted what you intend to do) cat /path/to/file/$file1 | while read a do mv /path/to/data/"$a" /path/to/new/location 2>/dev/null echo "Moved File" $a" >>/path/to/file/logs/filesmoved$year$month$day.txt 2>/dev/null done |
|
||||
|
Try to change your script as follows:
while read a do var1=`echo "$a"` mv /path/to/data/"$var1" /path/to/new/location #Use double quote echo "Moved File" $var1 >> /path/to/file/logs/filesmoved$year$month$day.txt done < /path/to/file/$file1 # No need to cat file in first line if you have this line. |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|