- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- simple calulation script...
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
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
тАО10-09-2001 01:45 AM
тАО10-09-2001 01:45 AM
I've got a number that is translated from a numberical string as follows:
numberical string: 1.1.100
(max 255.255.255)
256^2 * X + 256^1 * Y + Z
ie 1.1.100 becomes
65892
How can I go backwards in a script?
Thanks,
Bill
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-09-2001 01:59 AM
тАО10-09-2001 01:59 AM
Re: simple calulation script...
----------cut here---------
#!/bin/sh
read input
OLDIFS=$IFS
IFS=.
set -- $input
echo $1 $2 $3
let sum=$1*256+$2
let sum=sum*256+$3
echo $sum
IFS=$OLDIFS
----------cut here---------
-Santosh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-09-2001 02:16 AM
тАО10-09-2001 02:16 AM
Re: simple calulation script...
echo $*
echo $1 | awk -F. ' { print $1*256^2 + $2*256 +$3 }'
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-09-2001 02:49 AM
тАО10-09-2001 02:49 AM
SolutionIf you mean convert a number back to x.y.z, then create a file containing:
{ for (i=3;i>=1;i--)
{ val[i]=256*($0/256-int($0/256))
$0=int($0/256)
}
printf ("%d.%d.%d\n",val[1],val[2],val[3])
}
echo 965892|awk -f/tmp/conv.awk
14.189.4
Rgds, Robin.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-09-2001 03:15 AM
тАО10-09-2001 03:15 AM
Re: simple calulation script...
How about this one ?
# V=65892
# echo `expr $V / 65536`.`expr $V % 65536 / 256`.`expr $V % 256`
1.1.100
#
Volker