How does the --exclude=PATTERN option work in the du command?

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' tells du to ignore all files that have a .log extension.
  • -h provides the output in a human-readable format (e.g., KB, MB).
  • /path/to/directory is 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!

0 Comments

no data
Be the first to share your comment!