The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
Google UNIX.COM


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Directory sizes loop optimization la_womn Shell Programming and Scripting 6 05-16-2008 08:05 PM
to compare total directory structure and get sizes of all f on two different servers mannam srinivas Shell Programming and Scripting 3 04-07-2008 01:21 AM
Script for checking and reporting file sizes in a directory. marconi Shell Programming and Scripting 1 04-03-2008 05:00 AM
PERL: How do I get both sizes of a matrix? foo.bar Shell Programming and Scripting 2 09-26-2007 02:25 PM
compare file sizes joli Shell Programming and Scripting 4 02-04-2005 02:52 PM

Closed Thread
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 09-24-2003
Registered User
 

Join Date: Jan 2002
Posts: 144
Directory sizes

Can someone tell me how to read these damn sizes.

i mean, i prefer to see sizes in MB but that is not the case when you do an ls -l on directories. i have a had time converting these to MB

just for verification purposes, what would a directory size like this = 3499990308 represent in MB
or something like this 29994??

or is there a rule i can follow to be able to calculate this crap on my own? honestly, if any revision needs to be made to unix, it should be the ability to make all these sizes VERY easy to read. unix is complicated enough to be wasting time on this nonsense
Forum Sponsor
  #2 (permalink)  
Old 09-24-2003
pressy's Avatar
solaris cultist
 

Join Date: Aug 2003
Location: Vienna / Austria (Europe) [EARTH]
Posts: 710
i make it this way:

GNU bash, version 2.05.0(1)-release (sparc-sun-solaris2.9)

# mkfile 56k test1
# mkfile 5354k test2
# ls -lh
total 10832
-rw------T 1 root root 56K Sep 24 14:40 test1
-rw------T 1 root root 5.2M Sep 24 14:41 test2
  #3 (permalink)  
Old 09-24-2003
pressy's Avatar
solaris cultist
 

Join Date: Aug 2003
Location: Vienna / Austria (Europe) [EARTH]
Posts: 710
........

by the way:

the "-h" is also useable for this output:

root@pressy.ips.at # df -h /dev/dsk/c0t0d0s0
Filesystem size used avail capacity Mounted on
/dev/dsk/c0t0d0s0 2.0G 2.0G 0K 100% /


greetings Preßy
  #4 (permalink)  
Old 09-24-2003
Perderabo's Avatar
Unix Daemon
 

Join Date: Aug 2001
Location: Washington DC Area
Posts: 8,354
Preßy,

ls -h is available only on GNU ls. So that is not a very general answer. Besides, the real thrust of the question is the mental conversion of bytes to megabytes.

3499990308 as displayed by ls represents bytes. To get it to megabytes, I want to drop the last 6 digits. 3499990308 is sort of how I "see" the number. Now I do evaluate that 990308 as I throw it away. I do that really by looking just at the leading nine. Since I am throwing away a "large" number, I add one to the number that I keep. 3499 + 1 = 3500 MB. Whether or not to add that one depends on the leading digit of what I threw away. If it's 5,6,7,8, or 9 then I add the one.

This is a compromise, I would use a more accurate algorithm if I were writing a program. But I can do this instantly and effortlessly.

Effectively, what I have done is to divide the number by 1,000,000. Perfect accuracy would have required dividing by 1,048,576. Using the bc program I see that the real answer is 3338 MB. With a file this big, I don't care about a lousy 162 MB.

29994 is too small. Well, ok, it is 0 MB. I simply never want to convert tiny sizes to megabytes. But kilobytes would work in this case. The rule is similiar to the above, but here I just drop 3 digits rather than 6. So I estimate that file at 30 KB. bc says the real answer is 29 KB. Again, close enough.

Notice that both of my estimates were high. That is guaranteed to be the case.
Google UNIX.COM
Closed Thread

Thread Tools
Display Modes




All times are GMT -7. The time now is 07:46 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0