For Programmers: Free Programming Magazines  


Home > Archive > AWK > May 2006 > help in selecting field









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author help in selecting field
rogv24@yahoo.com

2006-05-22, 6:57 pm

I am trying to read line 4 and then select the second field of that
line.
I can do it with two statements.
How can I combine them into one statement?

awk ('NR==4' && '{print $2}') /tmp/info4

This statement doesn't work.

thank you

Chris F.A. Johnson

2006-05-22, 6:57 pm

On 2006-05-22, rogv24@yahoo.com wrote:
> I am trying to read line 4 and then select the second field of that
> line.
> I can do it with two statements.
> How can I combine them into one statement?
>
> awk ('NR==4' && '{print $2}') /tmp/info4
>
> This statement doesn't work.


awk 'NR == 4 { print $2; exit }' /tmp/info4

--
Chris F.A. Johnson, author <http://cfaj.freeshell.org>
Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)
===== My code in this post, if any, assumes the POSIX locale
===== and is released under the GNU General Public Licence
rogv24@yahoo.com

2006-05-22, 6:57 pm

thanks

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com