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

how to: get the actual size used by a directory

Status
Not open for further replies.

zyrag

IS-IT--Management
Dec 4, 2002
252
PH
i want to know the size used by a directory. the dir contains around 50 files, but i dont know how to get the overall or the sum of the file sizes of these files. will i need to do scripting? i haven't tried creating one, where could i start? i want to learn scripting also..

thanks,
 
Hi,

du -s dirname :
Displays the total disk usage for all files in a directory in 512bytes.

du -ks dirname : Again displays the total disk usage for all files in a directory but calculates the block count in 1024-byte units rather than the default 512-byte units.

du -a dirname :
Displays the total disk usage for all files in a directory.

Best Regards,
vivek
 
Another useful variation of this command is: du -sk * | sort -n. This lists each file and its size and sorts the list with the largest file at the bottom of the list.

It's useful when you want to see what is taking up so much space in a directory.

 
I like to use my little home-grown awk script:

ls -lR /dir | awk '{sum += $5}; END {print sum}'
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top