Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Using nawk, how to print all first names containing four characters? I tried nawk ‘/^[[:alpha:]]{4}/{print $1}’ inputfile but didn't work

Mike Harrington:(510) 548-1278:250:100:175

Christian Dobbins:(408) 538-2358:155:90:201

Susan Dalsass:(206) 654-6279:250:60:50

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

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

Tom Savage:(408) 926-3456:250:168:200

share|improve this question
    
"Didn't work" means...? –  Ignacio Vazquez-Abrams Oct 17 '12 at 17:08
2  
You seem to be asking a lot of sed/awk-related questions without ever accepting the answers, or even bothering to read an awk tutorial... –  grawity Oct 17 '12 at 17:15
3  
Hi Steve! Please go through your existing questions once again and see which answers helped you the most. You can accept them by clicking the green checkmark next to them and should do so, as otherwise users might stop answering your questions. Also, as @grawity mentioned, you really need to show a little more research effort – we can certainly help you, but you need to show what you've tried in the first place. –  slhck Oct 17 '12 at 17:17

1 Answer 1

up vote 2 down vote accepted

Where someFile contains the data that you have supplied:

nawk '{if(length($1)==4){print $1}}' someFile

Output:

 Mike
 Jody
 Chet
share|improve this answer
    
This works fine. Thank you. –  Steve Oct 17 '12 at 23:21

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.