How Do I Skip Certain Directories In “du” Output?
- 0
- Add a Comment
On a mailing list I’m on, someone asked an interesting question about the du command: “I want to figure out how much disk space I’m using in different directories, but I don’t know how to exclude certain directories from the output. Anyone have a suggestion?”
My initial response was that you’d want to just pour the output through a grep -v, or, if you want to get fancy and use a regular expression, grep -vE. Like this:
du * | grep -vE ‘(/usr/|/bin/|/mnt/)’
which would give you an exhaustive output of disk usage by directory, but would skip any directories that matched the pattern /usr/ or /bin/ or /mnt/
[Continued at Ask Dave Taylor!]
