The --exclude=PATTERN option in the du command is used to exclude files and directories that match a specified pattern from the disk usage calculation. This can be helpful when you want to focus on specific parts of a directory tree without including certain files or subdirectories.
Example Usage
du --exclude='*.log' -h /path/to/directory
In this example:
--exclude='*.log'tellsduto ignore all files that have a.logextension.-hprovides the output in a human-readable format (e.g., KB, MB)./path/to/directoryis the target directory you want to analyze.
Notes
- You can use wildcards (
*,?) in the pattern to match multiple files. - This option is useful for excluding temporary files, logs, or any other files you don't want to include in the size calculation.
Feel free to ask if you need more examples or further clarification!
