Results 1 to 2 of 2
Hi,
I am trying to get the total file size for certain files per directory.
I am using
find `pwd` /DirectoryPath -name '*.dta' -exec ls -l {} \; | awk ...
- 03-26-2010 #1Just Joined!
- Join Date
- Mar 2010
- Posts
- 1
Getting the disk usage for certain files per directory.
Hi,
I am trying to get the total file size for certain files per directory.
I am using
find `pwd` /DirectoryPath -name '*.dta' -exec ls -l {} \; | awk '{ print $NF ": " $5 }' > /users/cergun/My\ Documents/dtafiles.txt
but this lists all the files in the directories.
I need the total per directory for all dta files.
Any suggestions?
- 03-26-2010 #2
Try this:
If you have many files and you just want to see the last line with the summary, use the following:Code:du -ch *.dta
But this only shows the directory you are in or have selected (i. e.)Code:du -ch *.dta | grep total
for your example.Code:du -ch /DirectoryPath/*.dta | grep total > /users/cergun/My\ Documents/dtafiles.txt
du in general can list an summarize sub directories but then, you can not select a filename.
If beside the .dta files there are only files ending with .bak, you can do this using the exclude option.
orCode:du -sh --exclude *.bak
for your example.Code:du -sh --exclude /DirectoryPath/*.bak | grep total > /users/cergun/My\ Documents/dtafiles.txt
If you have multiple filetypes you can put those in a file and call it duexlude.lst and then call it as follows.
hope this helps. Try man du for more options.Code:du -sh -X duexclude.lst /DirectoryPath/*.bak | grep total > /users/cergun/My\ Documents/dtafiles.txt


Reply With Quote