Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dividing large numbers 1

Status
Not open for further replies.

rgaskill1

Technical User
Jul 18, 2002
23
GB
Hi,
I am trying to modify a script to convert a file size in bytes to Mb.

I have tried using let for this, but this doesn't seem to work for large numbers, eg:-

x=34358697984
let y=$x/1048576
echo $y
0

Is there another way of doing this?

Regards
Richard

 
try pipe bc

echo "4343434343434/1024" | bc

Mike

"Whenever I dwell for any length of time on my own shortcomings, they gradually begin to seem mild, harmless, rather engaging little things, not at all like the staring defects in other people's characters."
 
What about this ?
x=34358697984
y=$(awk 'BEGIN{print '$x'/1048576}')
echo $y

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
In Korn shell...
Code:
x=34358697984
(( x /= 1048576 ))
print $x
 
btw ksh-93 will do floating point

Mike

"Whenever I dwell for any length of time on my own shortcomings, they gradually begin to seem mild, harmless, rather engaging little things, not at all like the staring defects in other people's characters."
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top