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 > 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
Problem In Shell Script satyakide Shell Programming and Scripting 11 09-24-2007 10:00 AM
Help! Problem with Shell Script. pektl Shell Programming and Scripting 7 05-29-2006 05:08 AM
Problem with SU or SSH in shell script sravanp UNIX for Dummies Questions & Answers 2 01-24-2006 12:00 PM
Shell Script problem bnohifi Shell Programming and Scripting 1 07-07-2005 02:02 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 12-07-2005
djt0506 djt0506 is offline
Registered User
  
 

Join Date: Nov 2005
Posts: 5
shell script problem

hi all.

im using the awk command to search a file for a matching number.

lets say the numbers in the file are 4588281, 4588282 and 4588283.

my problem is when i search for 8, the three numbers above appear. I want to have it so that if i search for any number that is not matching EXACTLY THE SAME as the three numbers above, then nothing will be returned from the awk command.

is there a way to do this? if so, how?

thanks all in advance for your replies.
  #2 (permalink)  
Old 12-07-2005
pondlife pondlife is offline
Registered User
  
 

Join Date: May 2004
Location: UK
Posts: 85
Searching for this OR that...

Hi,

I think this is what you're after:

awk '/4588281/ || /4588282/ || /4588283/ { print $0 }' test

Where test is your input file.

HTH,

pondlife
  #3 (permalink)  
Old 12-07-2005
mona's Avatar
mona mona is offline
Registered User
  
 

Join Date: Nov 2005
Location: Singapore
Posts: 96
Quote:
Originally Posted by djt0506
hi all.

im using the awk command to search a file for a matching number.

lets say the numbers in the file are 4588281, 4588282 and 4588283.

my problem is when i search for 8, the three numbers above appear. I want to have it so that if i search for any number that is not matching EXACTLY THE SAME as the three numbers above, then nothing will be returned from the awk command.

is there a way to do this? if so, how?

thanks all in advance for your replies.
try this ..

in grep

Code:
egrep -v '4588281|4588282|4588283' test
in awk

Code:
awk '$0 !~ /4588281/ && $0 !~ /4588282/ && $0 !~ /4588283/ { print $0 }' test
Sponsored Links
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 06:15 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