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!

Unix directory disk space 1

Status
Not open for further replies.

fatchoy

MIS
Jul 19, 2001
31
0
0
JP
Hi

Have a simple question ,I can't remember the command to
check the disk space used by a directory that contain some files.
It is not ls -l cause it wont show the total diskspace used by all the files .I also do not wan wish to use du command cause manually still need some caculation involved.

Can anyone advise.

Thanks
 
Try du -k . | tail -1 That should give you the total for the current dir in Kb
 
Total size (in bytes) of all files in a directory is given by...

ls -l | awk '/^-/ {sum+=$5} END {print sum}'


 
I vote du -k, just remember to specify a directory name if you don't want them all..

Bob
 
Hi Ygor

Your solution works fine.

I did not understand the syntax of awk.

What is the purpose for using '/^-/ in awk

I appreciate if you can explain this.

Thanks in advance
Mallik
 
It means that the line must start ([tt]^[/tt]) with a hyphen ([tt]-[/tt]).

//Daniel
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top