- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: ksh: max value of integer?
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
09-19-2002 08:49 AM
09-19-2002 08:49 AM
When files can be larger than 2Gb can the size still be assigned to a ksh integer? What is the maximum number a ksh variable can hold?
On some of the servers the gzip has not be ugraded to handle files larger than 2Gb so I want part of a script to do an error check and compare the size of a file to 2,147,283,648. I have been looking around a lot but have not come across any information about using larger numbers in shells. Do the companies which have very large files have to use another language such as perl or tcl to be able to user numbers larger than 2,147,283,648 or 4,294,967,296 (4 Gb)?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-19-2002 08:59 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-19-2002 09:04 AM
09-19-2002 09:04 AM
Re: ksh: max value of integer?
- Lawrence
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-19-2002 09:12 AM
09-19-2002 09:12 AM
Re: ksh: max value of integer?
You can use 'bc' in a shell to do arithmetic that involves numbers greater than 2^32-1 and/or to do real (not integer) arithmetic:
# X=1;Y=8;echo "scale=3\n $X/$Y"|bc
# echo "(2^33-1)/3"|bc
The output can be examined as a string and passed (again) to 'bc' for further calculation.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-19-2002 03:20 PM
09-19-2002 03:20 PM
Re: ksh: max value of integer?
#!/usr/bin/sh
FILE=$1
print "Use du -k to get size"
TWO_GB=2096956
KB=`du -k $FILE | awk '{print $1}'`
print "KB is $KB TWO_GB is $TWO_GB"
if [[ $KB -gt $TWO_GB ]]
then
print "File is more than 2 gb"
else
print "File is less than 2 gb"
fi
print "Use actual file size "
FSIZE=`ls -l $FILE | awk '{print $5}
print "FSIZE is $FSIZE "
if [[ $FSIZE -gt 2147283647 ]]
then
print "File is more than 2 gb"
else
print "File is less than 2 gb"
fi
This gave results of
Use du -k to get size
KB is 2635792 TWO_GB is 2096956
File is more than 2 gb
Use actual file size
FSIZE is 2699042816
File is less than 2 gb
The use of bc is interesting but I could not set a return code for true or false.
As disk drives get larger so will the use of arbitrary length integers.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-06-2002 06:09 PM
10-06-2002 06:09 PM
Re: ksh: max value of integer?
ftp://contrib:9unsupp8@hprc.external.hp.com/sysadmin/coolscripts/
Netscape and Opera work fine with an ftp URL but newer Internet Exploders will hang if the folder view is enabled (which is the dumb default). Turn it off in the Tools->Internet->Advanced menu.
Bill Hassell, sysadmin