system admin toolbox are you with “it”?
Jun 12

Use find to file a file that’s over 20 MB in size:

$ find / -type f -size +20000k -exec ls -lh {} \; | awk ‘{ print $9 “: ” $5 }’

  • find: use to find file, directory, etc.
  • /: Path to look in
  • -type: file type, in this case regular file
  • -size: specify the file size, in this case we’re going to look for 20,000k, use K (for KB)
  • -exec: execute additional command
  • ls -lh: list directory content using long list format in a human-readable format
  • {}: is the variable that get replaced with the file name
  • \; the back-slash is the escape character while the semicolon will end the exec command
  • |: pipe it
  • awk: pattern scanning
  • ‘{: start
  • $9: print the content of the 9th column
  • : separate the column with the colon
  • $5: print the content of the 5th column
  • }’: end

Leave a Reply