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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to find the file size in GB 3

Status
Not open for further replies.

scottpeter

Programmer
Sep 23, 2003
28
0
0
US
I have a directory. I need to find out the size of the files in the directory in GB's. How can I do this?

Thanks,
Scott
 
I am using GNU/Linux.

Tony the command does not do anything. It just displays the listing with the number of bytes. How can I get the values in GB's?

Sorry If I am being dumb, I am not too familiar with Linux/Unix.


Thanks,
Scott



 
a starting point:
ls -l | awk '{s=$5/1024/1024/1024;printf "%s\t%3.3f Gb\n",$0,s}'

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
As far as I can see, --block-size in Linux will only have an effect, if used together with -s; so try this:
ls -ls --block-size=1GB
And look at the first number in your lines.

hope this helps
 
Hoinz, even 'ls -ls --block-size=1GB' did not work on my system.

I did it using the following 'du -b *' which gives the disk usage in bytes and converted it into GB.

PHV, I tried your program after I was done. It works perfectly.........

Thank you everybody for the help.

Cheers,
Scott


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top