LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   du --exclude='pattern' only opposite? (https://www.linuxquestions.org/questions/linux-newbie-8/du-exclude%3Dpattern-only-opposite-4175451131/)

ctav01 02-21-2013 10:07 AM

du --exclude='pattern' only opposite?
 
Is there a way to find disk usage for a particular file pattern (ie. '*.tmp')?

Habitual 02-21-2013 10:37 AM

Code:

du -sh /path/to/file

shivaa 02-21-2013 10:56 AM

Quote:

Originally Posted by ctav01 (Post 4896767)
Is there a way to find disk usage for a particular file pattern (ie. '*.tmp')?

Yes, once check manual of du here. It says:
Code:

Synopsis

du [OPTION]... [FILE]...
du [OPTION]... --files0-from=F

Note: For /tmp you should be root.

Code:

~$ du -sk /tmp

ctav01 02-21-2013 12:07 PM

From what I've read, the "--files0-from=F" option lets me input filenames from a text file or stdin but neither does what I want. And I'm not looking to see the disk allocation from a directory. I want to see the disk usage by file pattern (ie. *.iso) in the current directory and sub-directories. Something like "du -sk *.bak" which doesn't work.

colucix 02-21-2013 12:56 PM

Maybe using something like
Code:

find . -name \*.iso -exec du {} +
You can also use the -printf action of find to display the disk usage:
Code:

find . -name \*.iso -printf "%k\t%p\n"

ctav01 02-21-2013 01:18 PM

Sweet, thank you very much.


All times are GMT -5. The time now is 11:36 PM.