To find large files in a directory on a Linux system, you can use the find
command with the -size
option. Here’s an example command:
find /path/to/directory -type f -size +100M
This will find all files larger than 100 MB in the specified directory and its subdirectories. You can adjust the size threshold by changing the +100M
argument to something else (e.g. +50M
for files larger than 50 MB).
The -type f
option limits the search to files only (excluding directories), and the /path/to/directory
argument specifies the directory to search in. You can replace this with a path to any directory on your system.
By default, the find
command will print out the paths of all files that match the search criteria. If you want to sort the output by file size, you can pipe the output to the du
and sort
commands, like this:
find /path/to/directory -type f -size +100M -print0 | du -h --files0-from=- | sort -hr
This will print out a list of files and their sizes in human-readable format (e.g. “10M” for 10 megabytes), sorted by size in descending order (i.e. largest files first).