The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

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



UNIX Desktop for Dummies Questions & Answers Discuss UNIX and Linux user interfaces like GNOME, KDE, CDE, and Open Office here. All UNIX and Linux Newbies Welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
how to extract last occurence of the field kcp_pavan Shell Programming and Scripting 3 03-12-2009 05:17 AM
extract a field by logic ChicagoBlues UNIX for Dummies Questions & Answers 4 01-27-2009 02:00 PM
need to extract field of characters in a line jansat Shell Programming and Scripting 3 05-22-2008 09:44 AM
How to extract field from variable more efective pp56825 Shell Programming and Scripting 11 01-19-2008 10:34 AM
Extract Part of string from 3rd field $3 using AWK stakuri Shell Programming and Scripting 4 10-10-2007 12:28 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #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.
  #2 (permalink)  
Old 04-29-2009
Ygor's Avatar
Ygor Ygor is offline Forum Staff  
Moderator
  
 

Join Date: Oct 2003
Location: -31.96,115.84
Posts: 1,407
var=$(awk 'NR==3{print $3}' file.txt)
Sponsored Links
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 06:16 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0