The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



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 !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
grep for pattern aemunathan Shell Programming and Scripting 12 05-09-2008 03:58 AM
How to grep this pattern?? askumarece Shell Programming and Scripting 13 02-20-2008 07:03 AM
help with grep the pattern bluemoon1 Shell Programming and Scripting 2 09-20-2007 12:27 PM
Appending to filename a string of text grep finds HLee1981 Shell Programming and Scripting 3 09-06-2005 03:44 PM
grep error message gammaman UNIX for Dummies Questions & Answers 3 07-11-2005 12:58 AM

 
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1 (permalink)  
Old 03-03-2006
silver123 silver123 is offline
Registered User
  
 

Join Date: Mar 2006
Posts: 2
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.
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 11:40 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0