- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- summing columns using awk
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-22-2002 02:05 AM
тАО08-22-2002 02:05 AM
cat run15 | awk -F"|" -f a.awk > out
here's the a.awk file..
# Add the 8th column and print the sum
{ s += $8 }
END { print "sum of the total account balance is... ", s }
here's the input file, run15, ..
"5937000004 "|392953|"EN"|"O"|"prueba"|20030927|20020810|+0000005.09|20020815|936
"5937000011 "|393712|"SP"|"S"|"MARIA EUGENIA"|20011004||+0000000.82|20020712|5
"5937000012 "|393713|"EN"|"S"|"ANGEL IGNACIO"|20020815|20020818|+12.86|20020810|939
"5937000018 "|605963|"SP"|"S"|"OMAR LERTORA"|20020812|20020712|+0000013.56|20020304|943
"5937000028 "|605962|"EN"|"D"|"OMAR LERTORA"|20020313||-0000014.82|20020304|944
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-22-2002 02:33 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-22-2002 02:44 AM
тАО08-22-2002 02:44 AM
Re: summing columns using awk
+_5.09
+__.82
======
+_5.91
+12.86
======
+18.77
+13.56
======
+32.33
-14.82
======
+17.51
Is, there something we are missing??
because here' my sample run:
# cat run15 | awk -F"|" -f a.awk
sum of the total account balance is... 17.51
# cat a.awk
{ s += $8 }
END { print "sum of the total account balance is... ", s }
#
live free or die
harry
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-22-2002 03:05 AM
тАО08-22-2002 03:05 AM
Re: summing columns using awk
The calculations just seem to work normal. We do not see the problem.
awk 'BEGIN{FS="|"}{sum=sum+$8}END{print sum}' inputfile
.. it just works fine: 17.51 in your example.
Tell us more about the exact problem you might have..
Regards,
Ceesjan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-22-2002 03:25 AM
тАО08-22-2002 03:25 AM
Re: summing columns using awk
If you aren't getting the same results we got, then I suggest you install the latest patch bundle!
live free or die
harry
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-22-2002 03:44 AM
тАО08-22-2002 03:44 AM
Re: summing columns using awk
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-22-2002 03:52 AM
тАО08-22-2002 03:52 AM
Re: summing columns using awk
I'm glad it was just patches and not our brains...hey, is it Friday yet?
live free or die
harry
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-22-2002 07:39 PM
тАО08-22-2002 07:39 PM
Re: summing columns using awk
:-D