![]() |
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 |
| UNIX for Advanced & Expert Users Expert-to-Expert. Learn advanced UNIX, UNIX commands, Linux, Operating Systems, System Administration, Programming, Shell, Shell Scripts, Solaris, Linux, HP-UX, AIX, OS X, BSD. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Grep and display n lines after the match is found. | cv_pan | UNIX for Dummies Questions & Answers | 3 | 09-25-2008 11:15 PM |
| if match found go to a particular line in perl | user_prady | Shell Programming and Scripting | 17 | 03-31-2008 03:00 PM |
| Remote login/copy command throwing an error | ashish_panpalia | UNIX for Dummies Questions & Answers | 1 | 02-12-2008 05:04 AM |
| sccs get -ek command is throwing err | Shivaprasad BS | Shell Programming and Scripting | 0 | 01-31-2008 05:49 AM |
| How do I prevent cron from returning errors on a file not found? | goodmis | Shell Programming and Scripting | 6 | 02-06-2007 10:14 AM |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
Hi
How to prevent grep command from throwing a system trap(or returning error status) if No match is found in the specified file(s) ? Consider this simple shell script: Code:
#!/usr/bin/ksh
trap 'STATUS=$?;set +x;echo;echo error $STATUS at line nb $LINENO executing :\
`sed -n "${LINENO}p" $0`;echo;exit $STATUS' ERR
#====== MAIN STARTS=========
cat server* | grep "ABC" > logfile.log
I want the file logfile.log to be empty if no match is found. But if, the file server* dont even exist, then I want trap to catch it and show the error. Please help... |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|