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

  • "Didn't work" means...? Oct 17, 2012 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... Oct 17, 2012 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, 2012 at 17:17

1 Answer 1


Where someFile contains the data that you have supplied:

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



You must log in to answer this question.

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