- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: awk query
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
Forums
Discussions
Discussions
Discussions
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
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
11-28-2003 01:04 AM
11-28-2003 01:04 AM
I want to total up the 5th Column of a text file. However, the total being printed is not printing/displaying in the correct format..I think my total is working fine but my printf is missing something..as follows:
cat $TRAFFIC | awk '{t1 +=$5}
END {printf("TRAFFIC TOTAL: "t1"")}' >> $TRAFFIC
Printf outputs as follows: e.g.
TRAFFIC TOTAL: 5.97367e+06
I think this is because the total will be quite a large number...I don't know how to display this correctly..?
Also, I want to convert & display this value from bytes into kb's & mb's...Any easy method anyone?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-28-2003 01:06 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-28-2003 01:07 AM
11-28-2003 01:07 AM
Re: awk query
printf("TRAFFIC TOTAL %12d\n",t1)
Rgds,
Jean-Luc
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-28-2003 01:10 AM
11-28-2003 01:10 AM
Re: awk query
man printf
Rgds,
Jean-Luc
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-28-2003 01:13 AM
11-28-2003 01:13 AM
Re: awk query
printf "TRAFFIC CONTROL %ld",t1
The simplest way to get your other answers is to divide by 1024 :)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-28-2003 01:13 AM
11-28-2003 01:13 AM
Re: awk query
you use printf, but provide no format string to format the number. You can print with or without leading zero and formatted to a specified number of digits.
{printf("Total %09d \n",t1)}
Nine digits with leading zeroes and newline.
greetings,
Michael