![]() |
|
|
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 |
| to pick up the Return Code ( RC) from the mailx command and return it to SAS uisng 's | manas6 | UNIX for Dummies Questions & Answers | 0 | 06-05-2008 07:44 AM |
| display the result of wc -l with words before and after the result | melanie_pfefer | UNIX for Dummies Questions & Answers | 3 | 04-30-2008 08:33 AM |
| pick the bug the server enters an infinite loop | arjunjag | High Level Programming | 3 | 07-19-2007 02:53 AM |
| New iteration of for-loop without incrementing? | jeriryan87 | Shell Programming and Scripting | 0 | 07-02-2007 03:13 PM |
| Regex to pick up name from the following including carriage return at end of the line | Shakey21 | Shell Programming and Scripting | 3 | 07-18-2002 09:27 AM |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
Pick up the return code for every iteration and display the result only once in loop.
Hi All,
I amlearning UNIX scripting. I have a small query. I would be thankful if any one helps me out. I have a below piece of code which delets the files. If file dosent have the permissions to delete a particular file I have used 2>>operator to track the error code. But my objective is to check the return of 'rm' for every iteration. Some thing like we should be picking up the return code, if its value is greater than 0 then you should set a flag to indicate that an error has occured. The flag should be initialised to zero before the iterations begin. And the error message some thing like 'Atleast one file cannot be deleted'. Example:-we need to remember using a flag (something like if [[ $? > 0 ]] then rm_errorflag=1). Need to use this in below piece of code ls -l | { while read myline; do if [[ -f "$myline" && "$myline" != *.ksh ]] then echo "Removing " "$myline" >> temp rm -f "$myline" 2>>temp fi done } Please help me out in this. Thanks for your time. Regards, Manas |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|