Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Possible Duplicate:
Using nawk, how to print all first names containing four characters?

Using nawk, how to print the first names for all those in the 916 area code? I've tried nawk ‘$3 ~ /(916)/{print $1}’ inputfile but didn' work.

Jody Savage:(206) 548-1278:15:188:150

Guy Quigley:(916) 343-6410:250:100:175

Dan Savage:(406) 298-7744:450:300:275

Nancy McNeil:(206) 548-1278:250:80:75

John Goldenrod:(916) 348-4278:250:100:175

Chet Main:(510) 548-5258:50:95:135

share|improve this question

marked as duplicate by Xavierjazz, Indrek, Hennes, Doug Harris, BBlake Oct 17 '12 at 18:38

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

I really hope these are not real phone numbers and the real names of these people. – Ramhound Oct 17 '12 at 18:01
up vote 1 down vote accepted

Try this :

nawk '$2 ~ "(916)" {print}' file.txt
share|improve this answer
Wow! works great.. thank you – Steve Oct 17 '12 at 20:05
You should "accept" the question then =) (Dunno if it's possible with a closed question) – Gilles Quenot Oct 17 '12 at 20:08

Not the answer you're looking for? Browse other questions tagged .