Post

Quick and dirty 'find' and 'du' trick

Want to know how much space the files you found with the 'find -name' command occupy? Try this:

1
find -name \*SOMEPATTERN\* -print0 | du -c --files0-from=- 

What happens here is:

  1. Add the '-print0' parameter to the find command to use 0 instead of newline after each file
  2. Add the '--files0-from=-' to instruct 'du' to read a 0-terminated list of filenames, the '-' specifies 'read from stdin'

Simple!

This post is licensed under CC BY 4.0 by the author.