LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
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 09-10-2009, 06:15 PM   #1
maas187
Member
 
Registered: Aug 2008
Location: Yemen
Distribution: Fedora, CentOS, RedHat , OpenFiler, ESXI
Posts: 225

Rep: Reputation: 32
Post Awk question .


HI to all.

I have a file that looks like this.


1.0,2.0
4.0,5.0
1.5,1.0

and so no .

i need to know how would i calculate this in AWK e.g.

1.0 X 2.0
4.0 X 5.0
1.5 X 1.0

and then
add the result ..... so multiply the numbers and add the result .

thank you very much
 
Old 09-10-2009, 06:19 PM   #2
maas187
Member
 
Registered: Aug 2008
Location: Yemen
Distribution: Fedora, CentOS, RedHat , OpenFiler, ESXI
Posts: 225

Original Poster
Rep: Reputation: 32
Quote:
Originally Posted by maas187 View Post
HI to all.

I have a file that looks like this.


1.0,2.0
4.0,5.0
1.5,1.0

and so no .

i need to know how would i calculate this in AWK e.g.

1.0 X 2.0
4.0 X 5.0
1.5 X 1.0

and then
add the result ..... so multiply the numbers and add the result .

thank you very much

Thank you guys already found it .


awk -F, '{s += $1*$2} END {print s}' file_list
 
  


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
awk question custangro Programming 6 08-03-2008 11:51 PM
awk question cmontr Programming 12 11-19-2007 11:35 AM
awk question davidkline Linux - General 9 09-29-2006 12:37 PM
awk question dilberim82 Programming 2 10-01-2003 07:12 PM

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

All times are GMT -5. The time now is 07:41 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