HPE GreenLake Administration
- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Caluclations in script
Operating System - HP-UX
1833653
Members
3572
Online
110062
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
Go to solution
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-07-2005 07:11 PM
09-07-2005 07:11 PM
My problem
i have some xml files whcih i'm intersted to convert in to a execl file and merge it.
i have planned to convert amd merge more then 25 files to sigle large file with a tab space so that i will be able to view as a exel file.
but each and every xml file is different from other so i cant use simple cat head and tail cmd.
now i'm thinking of using line numbers.
Need Solution
for this i want to do some calculations in the script i want my script to add $TT with 141
where $TT will be changing how to do this.
i have some xml files whcih i'm intersted to convert in to a execl file and merge it.
i have planned to convert amd merge more then 25 files to sigle large file with a tab space so that i will be able to view as a exel file.
but each and every xml file is different from other so i cant use simple cat head and tail cmd.
now i'm thinking of using line numbers.
Need Solution
for this i want to do some calculations in the script i want my script to add $TT with 141
where $TT will be changing how to do this.
Solved! Go to Solution.
3 REPLIES 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-07-2005 07:17 PM
09-07-2005 07:17 PM
Solution
First, be aware that shell calculations are limited to integer values. so sticking it to shell arithmatic is not a good idea.
you can do it as follows.
total=$(($TT+2))
Better way to do it, is with bc/bs
echo "$TT+96" | bc
echo "$TT+96" | bs
you can do it as follows.
total=$(($TT+2))
Better way to do it, is with bc/bs
echo "$TT+96" | bc
echo "$TT+96" | bs
There is no substitute to HARDWORK
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-07-2005 08:12 PM
09-07-2005 08:12 PM
Re: Caluclations in script
Have a look at the arithmetic evaluation section in the manpage of sh-posix.
Bear in mind that the shell's arithmetic capabilities are however somewhat restricted
(compared to most scripting or programming languages, or programs such as bc)
The manpage will tell you.
Nevertheless you can define shell variables to be treated as integers explicitly by the typeset built-in.
Variables marked such can easily be evaluated in double parentheses.
e.g.
$ typeset -i line_no=0; while read line; do printf "%0.4d\n" $((line_no+=1));done < /etc/hosts|tail
0049
0050
0051
0052
0053
0054
0055
0056
0057
0058
If you were using a Perl script you could refer to the special package global $.
which holds the current line number
(see "perldoc perlvar" for further explanations)
Bear in mind that the shell's arithmetic capabilities are however somewhat restricted
(compared to most scripting or programming languages, or programs such as bc)
The manpage will tell you.
Nevertheless you can define shell variables to be treated as integers explicitly by the typeset built-in.
Variables marked such can easily be evaluated in double parentheses.
e.g.
$ typeset -i line_no=0; while read line; do printf "%0.4d\n" $((line_no+=1));done < /etc/hosts|tail
0049
0050
0051
0052
0053
0054
0055
0056
0057
0058
If you were using a Perl script you could refer to the special package global $.
which holds the current line number
(see "perldoc perlvar" for further explanations)
Madness, thy name is system administration
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-08-2005 03:13 AM
09-08-2005 03:13 AM
Re: Caluclations in script
Hi
Thanks for your reply.
As if i'm going to use only addition not more than 3 digits i hope the answer you people provided will do.
Thank You.
And i'm using the procedure give by RAC as if that is very easy one to follow.
Thanks for your reply.
As if i'm going to use only addition not more than 3 digits i hope the answer you people provided will do.
Thank You.
And i'm using the procedure give by RAC as if that is very easy one to follow.
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