LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 02-21-2013, 10:07 AM   #1
ctav01
LQ Newbie
 
Registered: Aug 2003
Location: Pleasanton, CA
Distribution: Gentoo
Posts: 23

Rep: Reputation: 0
du --exclude='pattern' only opposite?


Is there a way to find disk usage for a particular file pattern (ie. '*.tmp')?
 
Old 02-21-2013, 10:37 AM   #2
Habitual
LQ Addict
 
Registered: Jan 2011
Posts: 8,355
Blog Entries: 11

Rep: Reputation: 2327Reputation: 2327Reputation: 2327Reputation: 2327Reputation: 2327Reputation: 2327Reputation: 2327Reputation: 2327Reputation: 2327Reputation: 2327Reputation: 2327
Code:
du -sh /path/to/file
 
Old 02-21-2013, 10:56 AM   #3
shivaa
Senior Member
 
Registered: Jul 2012
Location: Grenoble, Fr.
Distribution: Sun Solaris, RHEL, Ubuntu, Debian 6.0
Posts: 1,800
Blog Entries: 4

Rep: Reputation: 286Reputation: 286Reputation: 286
Quote:
Originally Posted by ctav01 View Post
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
 
Old 02-21-2013, 12:07 PM   #4
ctav01
LQ Newbie
 
Registered: Aug 2003
Location: Pleasanton, CA
Distribution: Gentoo
Posts: 23

Original Poster
Rep: Reputation: 0
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.
 
Old 02-21-2013, 12:56 PM   #5
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978
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"

Last edited by colucix; 02-21-2013 at 01:03 PM.
 
Old 02-21-2013, 01:18 PM   #6
ctav01
LQ Newbie
 
Registered: Aug 2003
Location: Pleasanton, CA
Distribution: Gentoo
Posts: 23

Original Poster
Rep: Reputation: 0
Sweet, thank you very much.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
rsync exclude pattern genese Linux - Software 3 12-03-2012 04:26 AM
rsync Include/exclude based on pattern & file size? Geremia Linux - Software 1 01-20-2012 08:49 PM
[SOLVED] how to exclude everything except a pattern with sed rafaeldeoliveiracosta Programming 12 07-23-2010 11:36 AM
CVS Exclude : Exclude sub directories from check out On Linux from command line shajay12 Linux - Newbie 1 08-03-2009 12:36 AM
Exclude file pattern from unzip command XeroXer Linux - Newbie 3 01-10-2009 07:10 AM


All times are GMT -5. The time now is 04:03 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration