The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
Google UNIX.COM



View Single Post in UNIX Forums - Click on the Thread or Permalink to View Entire Thread -->
  #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
Reply With Quote