- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- [Q] asking for korn shell, specially summation of ...
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
тАО07-05-2006 11:22 PM
тАО07-05-2006 11:22 PM
[Q] asking for korn shell, specially summation of float ..
I have a file contain like this information.
infodba@/home/infodba/temp$ head 1st.rst
KRBPGWDCAD00001 35280 1 50.076 0.14%
KRBPGWDCAD00002 35280 1 0.703 0.00%
KRBPGWDCAD00003 35280 1 2.04 0.01%
KRBPGWDCAD00004 35280 1 8.831 0.03%
...
I would like to sum $4 to one variable.
However, it is float number and I have no idea how it sum to one values.
Could you let me know how the $4 can be summed using "for" command ?
Additionally, I would like to know how $2 (integer) and $4 (float) can be divided ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-05-2006 11:27 PM
тАО07-05-2006 11:27 PM
Re: [Q] asking for korn shell, specially summation of float ..
awk '{(s+=$4)} END {printf "%d\n",s}' your_file
- Tags:
- awk
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-06-2006 12:05 AM
тАО07-06-2006 12:05 AM
Re: [Q] asking for korn shell, specially summation of float ..
Sum:
# awk '{(s+=$4)} END {printf "%6.3f\n",s}' 1st.rst
Overall quotient:
# awk '{d+=$2;n+=$4} END {printf "%f\n",(n/d)}' 1st.rst
Quotient by line:
# awk '{printf "%f\n",($4/$2)}' 1st.rst
PCS
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-06-2006 04:08 AM
тАО07-06-2006 04:08 AM
Re: [Q] asking for korn shell, specially summation of float ..
Now if I just would be able to find the ksh93 release notes. (google has only one hit for them, and I don't remember the magic string)
- Tags:
- dtksh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-06-2006 04:44 AM
тАО07-06-2006 04:44 AM
Re: [Q] asking for korn shell, specially summation of float ..
Bill Hassell, sysadmin