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

how to know the size of a folder by command

Status
Not open for further replies.

12345671

IS-IT--Management
May 24, 2003
106
AU
Command
ls -alh

show the file and folder, and the size of fils,but how can I know the size of the foler by command line?

 
du <foldername> to see space for <foldername> and sub-folders, or du -s <foldername> to see only the total.
 
Try this:
Code:
wc -c MyFolder/* | tail -1


----------------------------------------------------------------------------
The person who says it can't be done should not interrupt the person doing it. -- Chinese proverb
 
Good,
du foldername -sh shows the size of the folder in MB
du foldername/* -csh shows subfolder sizes and total size

wc -c foldername/* |tail -1 shows the bytes, not in MB.

Anyway, look like ls cannot do this job.
 
OK, MB:
Code:
echo "$(wc -c MyDir/* | tail -1|awk '{print $1/1024/1024;}') MB"

----------------------------------------------------------------------------
The person who says it can't be done should not interrupt the person doing it. -- Chinese proverb
 
You must be a good linux script programmer:)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top