LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   DU command - summary of files and folders (https://www.linuxquestions.org/questions/linux-newbie-8/du-command-summary-of-files-and-folders-888187/)

ktfreak 06-24-2011 03:27 PM

DU command - summary of files and folders
 
Hi guys,

I use the following command to find files which are older than 60 days:
find /myfolder/* -mtime +60 > /myfolder/file.list

Now I want to find out the file size of all files contained in file.list in summary using the du command:
less /myfolder/file.list | xargs du -sh

The du command prints the file sizes of every single file but not the summary and this is actually what I want.

Does anyone have an idea?

Thanks,

acid_kewpie 06-24-2011 04:21 PM

If you read the manpage you'll see the -c option for a total.

lithos 06-24-2011 05:11 PM

interesting,
I think that du doesn't work on file list, but in the directory.
Code:

find /mydir/* -mtime -60 | xargs du -hs
du: invalid option -- p
du: unrecognized option `--dport'
du: invalid option -- j
Try `du --help' for more information.
xargs: unmatched single quote; by default quotes are special to xargs unless you use the -0 option

so there is a catch probably how to do it with a file list?

otherwise "du" gives me:
Code:

du /etc/postfix/ -hcs
564K    /etc/postfix/
564K    total


ktfreak 06-24-2011 05:18 PM

Damned!
I was so focused by the -s parameter that indeed doesn't work with the retrieving files from a file method...

In addition, the command 'grep total' turns this in a nice piece of work I think:)
less /myfolder/file.list | xargs du -csh | grep total

I can work with that...

thanks


All times are GMT -5. The time now is 01:31 PM.