Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

This is probably something basic but I'm not able to make it work. I'm trying to use DU to get a total size of files minus certain directories. I need to exclude one specific directory called uploads but not every directory called uploads. For example, my file structure looks a bit like this:

/store
  /uploads
    /junk_to_ignore
    /more_junk_to_ignore
  /user_one
    /uploads
  /user_two

I can run the following command:

du -ch --exclude=uploads* 

and it gives me the file size minus all the "uploads" directories. However, in trying to exclude certain directories (and all its sub-directories) I fail. I've tried variations of:

du -ch --exclude=./uploads*
du -ch --exclude='/full/path/to/uploads/*'

but can't seem to figure it out. How do I exclude a specific directory?

share|improve this question
    
username: store$ du -ch --exclude=./uploads worked (with and without the wildcard) for me, from within the store directory. Are you running that command exactly and from within the store folder? And it has to be the relative path (that find sees/prints), not absolute. –  Kevin Oct 31 '11 at 18:19

1 Answer 1

up vote 12 down vote accepted

You've almost found it :)

du -ch --exclude=./relative/path/to/uploads

Note no asterisk at the end. The asterisk means all subdirectories under "upload" should be omitted - but not the files directly in that directory.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.