LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 10-15-2010, 01:04 PM   #1
Abid Malik
LQ Newbie
 
Registered: Sep 2010
Posts: 25

Rep: Reputation: -1
Question awk


Hello Everyone!

here is a statement of shell script

awk '// { num=$6 }' file.txt
echo $num


so in the above statement i actually want to copy the six'th column of file.txt into a variable num. but it's not copying the value in num.
 
Old 10-15-2010, 01:18 PM   #2
druisgod
Member
 
Registered: Jun 2004
Location: Maine
Distribution: LFS Mint OS, LFS, CENTos,
Posts: 119

Rep: Reputation: 18
I'm not sure what you are doing with the awk statement with the slashes and such, but I would do it like this:

num=`awk '{print $6}' file.txt`

echo $num

That says "The variable num is equal to the result of this command: awk . . ."
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
awk question on handling *.CSV "text fields" in awk jschiwal Programming 8 05-27-2010 06:23 AM
[SOLVED] awk: how can I assign value to a shell variable inside awk? quanba Programming 6 03-23-2010 02:18 AM
awk , I need help for awk, just a display function mcandy General 1 12-15-2008 12:21 PM
shell command using awk fields inside awk one71 Programming 6 06-26-2008 04:11 PM
Some comments on awk and awk scripts makyo Programming 4 03-02-2008 05:39 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 08:06 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration