AWK quiz


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting AWK quiz
# 1  
Old 05-20-2009
AWK quiz

How come every post in this forum is a request for help?
How about some fun?

What does the following command do?

Code:
nawk -F'[^A-Za-z_]+' '
{i=NF;for(;i;i--)if($i)w[tolower($i)]++}
END{
  for(k in w){c=w[k];x[c]=x[c]k",";if(c>m)m=c}
  for(;m;m--)if(m in x)print m,x[m]
  }
' <(man nawk)


Last edited by colemar; 05-21-2009 at 05:53 AM.. Reason: A minor problem in the awk code
# 2  
Old 05-20-2009
In most shells it produces a syntax error.
# 3  
Old 05-20-2009
Quote:
Originally Posted by cfajohnson
In most shells it produces a syntax error.
You know that's not the point.

Code:
 
man awk | awk ...

Now, what does it do?
Login or Register to Ask a Question

Previous Thread | Next Thread

5 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Quiz help!

Hello, I'm new to Unix and need help answering these questions if possible, thanks. --------------------------------------------------------------------------------------- In a shell script, which command could be place at the end of a command line to combine stderr and stdout into the stdout... (1 Reply)
Discussion started by: julianpeters
1 Replies

2. AIX

HACMP pop quiz

Hi all, A pop quiz is being organized in my project and I've been appointed as one of the quiz-masters. This is a sample of what we are bringing forth. Feedback is welcome. 1)Name 2 commands used to display cluster state, but doesn't use the clinfoES daemon: a) ... (0 Replies)
Discussion started by: themetalingus
0 Replies

3. Shell Programming and Scripting

AWK quiz, multiple choice

Nobody cared about the original post, or perhaps it was a bit difficult to guess. Therefore I am including a poll here. nawk -F'+' ' {i=NF;for(;i;i--)if($i)w++} END{ for(k in w){c=w;x=xk",";if(c>m)m=c} for(;m;m--)if(m in x)print m,x } ' <(man nawk) (6 Replies)
Discussion started by: colemar
6 Replies

4. Programming

C Programming Quiz

Hey check this out..it's only a 10 question quiz..but it's brain storming. http://mulogic.phpnet.us/drupal I scored 7/10 (3 Replies)
Discussion started by: luv2beuniq
3 Replies

5. UNIX for Dummies Questions & Answers

Question for school quiz

I have these questions for my unix class that I can't figure out because I missed a couple of days. They are for a quiz we took last week so by answering the questions you are not bettering my grade or doing my homework. I just want to understand was the answers. My teacher is really bad at... (1 Reply)
Discussion started by: djeung
1 Replies
Login or Register to Ask a Question