AI Hints
Home›Linux Tutorial›Finding Files
Linux · Lesson 39 of 120

find: Type, Size and Time

More ways to search.

⏱ 2 min read▶ Video at 49:26🎓 Free
Watch this lesson in the Linux courseWatch on YouTube ↗Full Linux course

Names are only one way to search. Find can also look for folders only, for big files that fill up your disk, or for files you changed recently.

find: Type, Size and Time
From the video: find: Type, Size and Time
  • Not just names
  • Folders, big files
  • Recent changes

Only folders, or only files

Dash type D finds only directories. Dash type F finds only normal files. Here we list every folder inside projects. It's a quick way to see the shape of a project.

Terminal
find projects -type d
projects
projects/website
projects/website/css
projects/scripts

Big files

Dash size, plus one M, means bigger than one megabyte. That's how you find what's filling up your disk. In our home, the only big file is a video in Downloads. Add dash LS at the end, to see its size and details too.

Terminal
find . -size +1M
./Downloads/video.mp4
find . -size +1M -ls
   880071   2444 -rw-r--r--   1 sam      sam       2500000 Jan  5 09:00 ./Downloads/video.mp4

Recent files, and doing things

Dash M time, minus one, finds files changed in the last day. Dash M min, minus thirty, means the last thirty minutes. Find can also do something to every file it finds, with dash exec, or delete them with dash delete. Always run find without dash delete first, to check the list.

keyvalue
-mtime -1changed in the last day
-mmin -30the last 30 minutes
-exec cmd {} \;run a command on each
-deletecareful: check first

Summary

Find can search by type, by size, and by time, and can act on what it finds. Next, shortcuts to files, called links, and checking disk space.

Key takeaways
  • -type d / -type f
  • -size +1M
  • -mtime -1
Next up: Links: Shortcuts to Files — ln -s