The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Special Forums > UNIX Desktop for Dummies Questions & Answers
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #1 (permalink)  
Old 04-28-2009
etownbetty etownbetty is offline
Registered User
  
 

Join Date: Nov 2007
Posts: 8
Extract third field of third line

Hi, how do I extract the third field of the first line?

I know how to get the first line or the third field of a file, but I can't get the single entry.

awk 'NR==1' file.txt

awk '{print $3}' file.txt

Please tell me how to combine these.

And how do I set this value into a variable?

var='awk "NR==1" file.txt'
?

But now I have to "eval" this $var, right?

I want to use $var in another expression.

Thanks for your help.