The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



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
How do I search for 2 strings (AND operator) ? Kartheg UNIX for Dummies Questions & Answers 14 09-11-2009 04:44 PM
problem with grep on search string in a txt file over multiple files m00 UNIX for Dummies Questions & Answers 2 05-18-2008 02:21 PM
how to search with 2 strings. syamkp Shell Programming and Scripting 2 03-10-2008 04:50 AM
Search between strings with an OR pbsrinivas Shell Programming and Scripting 3 07-12-2007 04:46 AM
Search for strings lesstjm UNIX for Dummies Questions & Answers 5 04-26-2002 09:58 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 10-25-2007
sudhish sudhish is offline
Registered User
  
 

Join Date: Jun 2007
Location: India, Kerala
Posts: 10
Problem to search multiple strings

Hi all,
I am search a string from a file using following command, I want to pick the message ( I.e print $5) from the lookup file if and only if both $hostname and $instancename match.
Message=`cat $lookup_tbl| awk '/'$category'/ {if ('$hostname' == '$2' || '$instancename' == '$3') print $5}'`
This work fine when I have different category but not with same category.
I.e. if $category=interface it work fine but when $category= Link_Availability getting both email id's in category (I.e soman@nvgnoc.com and sudir@nvgnoc.com)

my lookup file like this

#Look up table############################################################################################### ###########
Catagory Hostname Instantname Subject Message E-mail Address
interface W2K3GNOC W2K3GNOC2 Message_from_netview W2K3GNOC_link_is_down nvpraveen@nvgnoc.com
Link_Availability TVMROUTER TVMROUTER2 Message_from_netview Asianet_Link_is_Down soman@nvgnoc.com
Link_Availability TVMROUTER TVMROUTER6 Message_from_netview VSNL_Link_is_Down sudir@nvgnoc.com
#################################################################################################### #####################

Please guide me to achieve this.

Regards
Sudhish
  #2 (permalink)  
Old 10-25-2007
matrixmadhan matrixmadhan is offline Forum Advisor  
Technorati Master
  
 

Join Date: Mar 2005
Location: leaf node in B+ tree
Posts: 2,944
Are they real email Ids ? If so please do not furnish such information
You could use something like abc@xyz.com
  #3 (permalink)  
Old 10-25-2007
matrixmadhan matrixmadhan is offline Forum Advisor  
Technorati Master
  
 

Join Date: Mar 2005
Location: leaf node in B+ tree
Posts: 2,944
Quote:
Link_Availability TVMROUTER TVMROUTER2 Message_from_netview Asianet_Link_is_Down so@so.com
Link_Availability TVMROUTER TVMROUTER6 Message_from_netview VSNL_Link_is_Down s@this.com

only one would be selected,
the common second field is ' TVMROUTER ' and the other value should be either ' TVMROUTER2 ' or ' TVMROUTER6 '

so only one row would be selected
Closed Thread

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 09:41 PM.


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