How To: Linux Find Large Files in a Directory

How To: Linux Find Large Files in a Directory

To find large files in a directory on a Linux system, you can use the find command with the -size option. The -size option allows you to search for files based on their size.

For example, to find all files in the current directory that are larger than 100MB, you can use the following command:

$ find . -size +100M
Source:ww‮uttual.w‬ri.com

This will search for files in the current directory (.) and all its subdirectories, and print the names of any files that are larger than 100MB. The + sign indicates that the search should include files that are exactly the specified size.

You can also use the -exec option to perform an action on the files that are found. For example, to delete all files larger than 100MB, you can use the following command:

$ find . -size +100M -exec rm {} \;

This will search for files in the current directory and all its subdirectories, and delete any files that are larger than 100MB. The {} symbol is replaced with the name of each file that is found, and the \; at the end indicates the end of the -exec command.

Note that the find command is very powerful and has many other options and features that you can use to fine-tune your search. For example, you can use the -type option to search for specific types of files (e.g. directories, regular files, symbolic links), and the -mtime option to search for files based on their modification time. You can use the man find command to learn more about these and other options.

Created Time:2017-10-29 22:08:34  Author:lautturi