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

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
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
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
up vote 2 down vote accepted

Where someFile contains the data that you have supplied:

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


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

You must log in to answer this question.

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