Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Find "*.log" files in your home dir, sort them by fattest-first, and calculate the size of them all together.
find ~ -name '*.log' -print0 | xargs -0 -L1 stat -f'%z %N' | sort -rn | tee fat-logfiles.txt | head
awk '{ total += $1 } END { printf "total: %5.2f MiB\n", total/1024/1024 }' < fat-logfiles.txt
@13k

This comment has been minimized.

Copy link

@13k 13k commented Feb 7, 2013

linux version:

find ~ -name '*.log' -print0 | xargs -0 -L1 stat -c '%s %N' | sort -rn | tee fat-logfiles.txt | head
awk '{ total += $1 } END { printf "total: %5.2f MiB\n", total/1024/1024 }' < fat-logfiles.txt
@henrik

This comment has been minimized.

Copy link

@henrik henrik commented Feb 7, 2013

Maybe /tmp/fat-logfiles.txt, not to litter your working dir.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment