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

-3

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

Steve

Posted 2012-10-17T17:04:11.753

Reputation: 287

"Didn't work" means...? – Ignacio Vazquez-Abrams – 2012-10-17T17:08:46.803

2You seem to be asking a lot of sed/awk-related questions without ever accepting the answers, or even bothering to read an awk tutorial... – user1686 – 2012-10-17T17:15:43.340

3Hi 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 – 2012-10-17T17:17:26.710

Answers

2

Where someFile contains the data that you have supplied:

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

Output:

 Mike
 Jody
 Chet

p_strand

Posted 2012-10-17T17:04:11.753

Reputation: 679