View Single Post
Old 06-15-2011, 09:16 AM  
fris
Too lazy to set a custom title
 
fris's Avatar
 
Industry Role:
Join Date: Aug 2002
Posts: 55,297
neat thing for the people that use the envato marketplace

you can't download all your statements in 1 file, only by month, I wanted to find a quick way to add up the totals amount spent, with awk and sed, you can do this in 1 command.

Thought I would share if anyone else can use this.

As you can see I have quite a few statements



two ways you can do it, using awk and sed or awk and printf (this is only used for adding commas mainly cosmetic)

awk and printf (relies on locale)

Code:
awk -F '^"|","|"$' '/-/{sum += $5} END {printf "$%'\''d spent\n",sum}' *.csv
awk and sed

Code:
awk -F '^"|","|"$' '/-/{sum += $5} END {print sum}' *.csv | sed 's/-//; s/^/$/; s/$/ spent/; s/\(.*[0-9]\)\([0-9]\{3\}\)/\1,\2/;t'
__________________
Since 1999: 69 Adult Industry awards for Best Hosting Company and professional excellence.


WP Stuff
fris is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote