HPE GreenLake Administration
- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Shel Script Calculation
Operating System - HP-UX
1834346
Members
2130
Online
110066
Solutions
Forums
Categories
Company
Local Language
back
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
back
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
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Topic Options
- 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
09-08-2006 11:01 PM
09-08-2006 11:01 PM
Shel Script Calculation
Hi,
Please find my shell script :
let Total=0
for i in `cat data1.dat`
do
let Total=$Total+1
done
echo $Total
I have series of integer number stored in data1.dat file.
If the range too huge, my calculation become wrong.
Please help.
Thanks
Please find my shell script :
let Total=0
for i in `cat data1.dat`
do
let Total=$Total+1
done
echo $Total
I have series of integer number stored in data1.dat file.
If the range too huge, my calculation become wrong.
Please help.
Thanks
3 REPLIES 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-09-2006 12:20 AM
09-09-2006 12:20 AM
Re: Shel Script Calculation
Hi,
Try to use awk or perl for calculations
HTH
Try to use awk or perl for calculations
HTH
Entities are not to be multiplied beyond necessity - RTFM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-09-2006 12:43 AM
09-09-2006 12:43 AM
Re: Shel Script Calculation
Hi:
You are limited by the shell's 32-bit arithmetic. As noted, by Victor, 'awk' or Perl would provide a solution. Based upon your example, to sum the first field found in your file, do:
# awk 'END{print N};{N+=$1+0}' data1.dat
Regards!
...JRF...
You are limited by the shell's 32-bit arithmetic. As noted, by Victor, 'awk' or Perl would provide a solution. Based upon your example, to sum the first field found in your file, do:
# awk 'END{print N};{N+=$1+0}' data1.dat
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-09-2006 01:56 AM
09-09-2006 01:56 AM
Re: Shel Script Calculation
thanks
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
Company
Events and news
Customer resources
© Copyright 2025 Hewlett Packard Enterprise Development LP