Shell One Liner: Sum file sizes

Ever wanted to find some files in a directory or by pattern and sum up their file size? A combination of find and du using pipe and tail does the trick. If you like byte size rather than human readable use du with -c instead of -hc.

$ find /PATH/TO/FILES/ -name "FILENAME*.EXAMPLE" -mtime -1 -print0 | du --files0-from=- -hc | tail -n1

Leave a Reply




This site uses Akismet to reduce spam. Learn how your comment data is processed.