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-17-2008 12:05 AM
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 05:21 AM
Script for checking and reporting file sizes in a directory. marconi Shell Programming and Scripting 1 04-03-2008 09:00 AM
PERL: How do I get both sizes of a matrix? foo.bar Shell Programming and Scripting 2 09-26-2007 06:25 PM
compare file sizes joli Shell Programming and Scripting 4 02-04-2005 06:52 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 09-24-2003
TRUEST TRUEST is offline
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
  #2 (permalink)  
Old 09-24-2003
pressy's Avatar
pressy pressy is offline Forum Staff  
solaris cultist
  
 

Join Date: Aug 2003
Location: Vienna / Austria (Europe) [EARTH]
Posts: 726
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
pressy pressy is offline Forum Staff  
solaris cultist
  
 

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

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
Perderabo Perderabo is offline Forum Staff  
Unix Daemon
  
 

Join Date: Aug 2001
Location: Ashburn, Virginia
Posts: 9,131
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.
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 04:37 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0