- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Division Operation
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
02-23-2005 03:30 AM
02-23-2005 03:30 AM
#let m=7
#let n=2
#let r=$m/$n
#echo $r
3
Only want the integer portion of calc so this is result needed.
How to guarantee that when run code on an arbitrary UNIX box it's going to return same precision ? How to incorporate precision of result into the code ?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-23-2005 03:40 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-23-2005 03:42 AM
02-23-2005 03:42 AM
Re: Division Operation
One of the method you can use is.
touch /tmp/anyfile
export m=7
export n=2
cat /tmp/anyfile | awk '{print '$m'/'$n'}'
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-23-2005 03:54 AM
02-23-2005 03:54 AM
Re: Division Operation
It's generally considered better form to type your variables so that
typeset -i m=7
is better than
let m=7
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-23-2005 03:54 AM
02-23-2005 03:54 AM
Re: Division Operation
echo "scale=0; 10/3" | bc
3
echo "scale=2; 10/3" | bc
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-23-2005 04:21 AM
02-23-2005 04:21 AM
Re: Division Operation
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-23-2005 04:28 AM
02-23-2005 04:28 AM
Re: Division Operation
Regarding your pointer on the uses of "let" vs. "typeset" what are the advantages of "typeset" :-)
here's a related question:
typeset -i p=50
typeset -i q=$p
typeset -i r=1
Have made the change you suggested for my uses of "let" but when "read" is used, what are the implications ? Is there a way to sort of use "typeset" when using "read" at the end of a string of piped ops ?
ls | wc -l | sed 's/^[ \t]*//;s/[ \t]*$//' | read histfilect
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-23-2005 04:35 AM
02-23-2005 04:35 AM
Re: Division Operation
typeset -i histfileect=0
ls | wc -l | sed 's/^[ \t]*//;s/[ \t]*$//' | read histfilect
The typeset applies to all following references of the variable.