Finding large files
Today I used the following snippet to find files larger than 1G in my home directory:
find ~ -type f -size +1G -exec \
du -hs {} \; | sort -rh
The find
command calls (-exec
) the du
command for each file (-type f
)
that is larger than 1G (-size +1G
). The option -hs
shows the size
in human readable format for each file. The result is piped to sort
which sorts on the human readable format (-h
) in reverse order
(-r
).
Note that the backslash in the snippet is used to continue the current line on the next one due to the width restriction of this blog. It should be immediately followed by a new line. Feel free to type the snippet on a single line, without the backslash.