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?
Best Answer
You've almost found it :)
Note no asterisk at the end. The asterisk means all subdirectories under "upload" should be omitted - but not the files directly in that directory.