The UNIX and Linux Forums  


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
While finding compare the result with given string mr_bold UNIX for Dummies Questions & Answers 4 04-24-2008 10:31 PM
compare string in two files MiLKTea Shell Programming and Scripting 2 03-10-2008 05:35 AM
Compare string to a pattern jerryte Shell Programming and Scripting 2 01-25-2008 08:37 PM
String compare sbasetty Shell Programming and Scripting 14 02-07-2007 05:24 AM
Compare Char to String Phobos High Level Programming 3 04-09-2005 12:01 PM

Closed Thread
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
  #1 (permalink)  
Old 03-23-2005
gundu gundu is offline
Registered User
  
 

Join Date: Mar 2005
Posts: 42
string compare

Hi,

I am trying to get an ouput of certain fields from a file:

awk '{ print $NF }' portfile

8087
8047
localhost:1117

Now i need to take this output and see if it exists in netstat -a command. How do i check that.

Thanks,
Gundu
  #2 (permalink)  
Old 03-23-2005
Marcos Brito Marcos Brito is offline
Registered User
  
 

Join Date: Mar 2005
Posts: 5
Hi Gundu. Try this:

LIST="`awk '{ print $NF }' portfile`"

if netstat -a |egrep -s "$LIST"
then
echo "do this"
else
echo "do that"
fi

Hope this helps.
  #3 (permalink)  
Old 03-23-2005
gundu gundu is offline
Registered User
  
 

Join Date: Mar 2005
Posts: 42
Thank you very much, it worked as expected
  #4 (permalink)  
Old 03-23-2005
Marcos Brito Marcos Brito is offline
Registered User
  
 

Join Date: Mar 2005
Posts: 5
You're welcome.
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 08:45 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