Find large files using Unix/Bash/Linux commands

The command you provided is a combination of several Unix/Linux commands that are used to find and list files in a directory.


find /directory -type f -size +sizek -exec ls -lh {} \; | awk '{ print $9 ": " $5 }'
  1. find Command:

    • The find command is used to search for files and directories in a specified directory.
    • -type f: This option tells find to search for regular files (not directories or other types of files).
    • -size +sizek: This part is used to specify a size filter. Replace size with a numeric value and k with a unit (e.g., k for kilobytes, M for megabytes). It finds files that are larger than the specified size.
  2. exec Option:

    • After finding files that match the specified criteria, the -exec option is used to execute a command on each found file.
    • ls -lh {} ;: Here, the ls -lh command is executed on each file to list their details in a human-readable format, including file size, permissions, owner, group, modification date, and filename.
  3. awk Command:

    • The awk command is used to format the output.
    • '{ print $9 ": " $5 }': This part extracts the 9th and 5th columns from the ls -lh output, which are the filename and file size, respectively. It then prints these two pieces of information in the format "filename: size."