- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Re: Scripting issue
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
тАО05-02-2007 08:34 PM
тАО05-02-2007 08:34 PM
I want to calculate the space using a script. When I used some command below, it gave me result 0.
PCT=44
USED=45260.8
((FLOATPCT=PCT / 100))
((TOTUSED=$FLOATPCT * $USED))
echo $FLOATPCT
echo $TOTUSED
Both was giving me 0 result. How can I modify the script, so the result of FLOATPCT=0.44 and TOTUSED=19914.752 instead?
Pls help.
Thanks and Best Regards,
Negara
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-02-2007 08:56 PM
- Tags:
- bc
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-02-2007 11:49 PM
тАО05-02-2007 11:49 PM
Re: Scripting issue
Another way is to use 'swk':
# awk -v PCT=44 -v USED=45260.8 'BEGIN{printf("%.2f\n",(PCT/100)*USED)}'
19914.75
Regards!
...JRF...
- Tags:
- awk
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-03-2007 03:14 AM
тАО05-03-2007 03:14 AM
Re: Scripting issue
#!/usr/dt/bin/dtksh
typeset -F PCT=44.0
typeset -F USED=45260.8
((FLOATPCT=PCT / 100))
((TOTUSED=$FLOATPCT * $USED))
echo $FLOATPCT
echo $TOTUSED
This now gives you the expected answers. Unfortunately, the HP man page for dtksh covers mostly the Xwindow enhancements and doesn't talk at all about typeset and integer versus floating point variables and math. Use this as your dtksh resource page:
http://www.kornshell.com/doc/
Bill Hassell, sysadmin
- Tags:
- dtksh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-03-2007 02:53 PM
тАО05-03-2007 02:53 PM
Re: Scripting issue
Thanks alot for your help. It's clear for me now.
Best regards,
Negara
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-03-2007 04:44 PM
тАО05-03-2007 04:44 PM
Re: Scripting issue
You can simulate it by multiplying the numerator by 10 to the power of the number of fractional digits, then manually placing the decimal point.
Of course this won't work well if the number overflows before the divide.