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

awk cmd-get total size of directory including subdirectories 1

Status
Not open for further replies.

rigstars1

Instructor
Oct 2, 2010
19
US
ls –lR |awk '{total +=$5};END {print "Total size: " total/1024/1024 " Mb"}'

I'm trying to get the total size of the current directory including subdirectories with this command. Can't figure out why it gives me this message. Can someone provide some guidance? Thanks!

ls: –lR: No such file or directory
Total size: 0 Mb
 
Why not simply use the du command ?

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
because I'm trying to use call this as a script in my customize prompt ..so when i go to any directory it will give me the total size of the directory I'm in automatically ..
 
du -ch | grep total | cut -f1

this does the trick for me ..
 
Why not simply this ?
du -sh | cut -f1

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
rigstars1 said:
so when i go to any directory it will give me the total size of the directory I'm in automatically
So when you go [tt]cd /[/tt] you're willing to wait a minute or so for your prompt to appear? ;-)

HTH,

p5wizard
 


Why not just select like from the following:
Code:
$ du -sh /opt/app/oracle/*
31M     /opt/app/oracle/admin
1.5M    /opt/app/oracle/cfgtoollogs
40M     /opt/app/oracle/diag
0       /opt/app/oracle/logs
0       /opt/app/oracle/lost+found
4.7G    /opt/app/oracle/media
12K     /opt/app/oracle/network
2.5M    /opt/app/oracle/oraInventory
4.2G    /opt/app/oracle/product
856K    /opt/app/oracle/scripts
[3eyes]


----------------------------------------------------------------------------
The person who says it can't be done should not interrupt the person doing it. -- Chinese proverb
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top