Linux Help
guides forums blogs
Home Desktops Distributions ISO Images Logos Newbies Reviews Software Support & Resources Linuxhelp Wiki

Welcome Guest ( Log In | Register )



Advanced DNS Management
New ZoneEdit. New Managment.

FREE DNS Is Back

Sign Up Now
> AWK
Larry
post Mar 29 2008, 05:35 PM
Post #1


Whats this Lie-nix Thing?
*

Group: Members
Posts: 1
Joined: 29-March 08
Member No.: 13,406



I'm trying to add a column of numbers which contain commas in a file called countries.txt; i.e, 123,456. The numbers are in the 2nd column of the file. The general structure of the command is:

awk '(tot+=$2); END {print "Total = " tot} countries.txt

When I execute this all I get is the sum of the numbers prior to the first comma. I know that I have to either parse the numbers or somehow get rid of the commas.

Can anyone tell me how to do this. Thanks.

Larry
Go to the top of the page
 
+Quote Post

Posts in this topic
- Larry   AWK   Mar 29 2008, 05:35 PM
- - markjr   You could rinse out the commas before it ever hits...   Mar 30 2008, 09:08 AM


Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



RSS Lo-Fi Version Time is now: 22nd October 2017 - 05:36 PM