How do I find the largest files in UNIX?

How do I find the largest files in UNIX?

Linux find largest file in directory recursively using find

  1. Open the terminal application.
  2. Login as root user using the sudo -i command.
  3. Type du -a /dir/ | sort -n -r | head -n 20.
  4. du will estimate file space usage.
  5. sort will sort out the output of du command.
  6. head will only show top 20 largest file in /dir/

How do I find the size of a file in Shell?

You can not get the size of a file in a bash script using an internal or built-in command. It would be best to use the stat and other commands under Linux to check the file size. The stat command displays information about the file including its size.

How to find large files in Linux shell?

Here then is a simple Linux shell script I named LargeFileCheck.sh, which searches the filesystem for files that are larger than 1GB in size: If the script finds any large files it sends me an email, otherwise it takes no action. Note that you can modify the find command maxdepth setting as desired.

How to find files larger than 500MB in command prompt?

In Command Prompt, forfiles command is used for batch processing a command on a file or set of files. The following command will find and list all files that are larger than 500MB in the C: drive. forfiles /P C: /M *.* /S /C “CMD /C if @fsize gtr 524288000 echo @PATH @FSIZE”

How to search for files bigger than 4 GiB?

To search for files bigger than 4 GiB in the entire filesystem, run: $ find / -type f -size +4G To know files bigger than X size in a specific directory, replace the dot (.) in the above command with the directory path like below. $ find Downloads/ -type f -size +4G

How to check the size of a file in Bash?

You should know that du shows the used disk space; and not the file size. You can use –apparent-size if u want to see sum of actual file sizes. And of course theres no need for -h (Human readable) option inside a script. Instead You can use -b for easier comparison inside script. But You should Note that -b applies –apparent-size by itself.