![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| grep for pattern | aemunathan | Shell Programming and Scripting | 12 | 05-08-2008 11:58 PM |
| How to grep this pattern?? | askumarece | Shell Programming and Scripting | 13 | 02-20-2008 04:03 AM |
| help with grep the pattern | bluemoon1 | Shell Programming and Scripting | 2 | 09-20-2007 08:27 AM |
| Appending to filename a string of text grep finds | HLee1981 | Shell Programming and Scripting | 3 | 09-06-2005 11:44 AM |
| grep error message | gammaman | UNIX for Dummies Questions & Answers | 3 | 07-10-2005 08:58 PM |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
#1
|
|||
|
|||
|
fixing the error message when grep doesn't finds the pattern.
Hi,
I am running the below script. --------------------------------------------------------- #!/bin/ksh for tname in `cat tables.txt | cut -f 1` ; do if (test -n `grep -il "$tname" /fs/scripts/*`) then echo ${tname} >> UsedTables.txt else echo ${tname} >> UnUsedTables.txt fi done --------------------------------------------------------- Its running fine if grep finds the pattern but when the pattern is not found its giving the following error message: script1.ksh[5]: test: argument expected Eventhough it throws the message but its appending the ${tname} value in the files. Can anyone let me know how to avoid the error message when grep doesn't finds the pattern. Thanks. |
| Forum Sponsor | ||
|
|
|
#2
|
||||
|
||||
|
Ygor had closed your earlier thread - script to search for the contents of a file on the grounds of violating the no-homework rule.
I will not give you any solution because its homework. But rather suggestions because you have a script that works partially. grep has a -q option. Read the man pages to see what it does. Use the exit status which results from that option and proceed. Read man ksh to see how you can use the construct ((expression)) together with the -q option. |
||||
| Google The UNIX and Linux Forums |