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:
find -name \*SOMEPATTERN\* -print0 | du -c --files0-from=-
What happens here is:
- Add the ‘-print0’ parameter to the find command to use 0 instead of newline after each file
- Add the ‘–files0-from=-‘ to instruct ‘du’ to read a 0-terminated list of filenames, the ‘-‘ specifies ‘read from stdin’
Simple!