Forrest logo
back to the find tool

find:tldr:9da7a

find: Find files modified in the last 7 days.
$ find ${root_path} -daystart -mtime -${7}
try on your machine

This command searches for files or directories in the directory specified by ${root_path} that were last modified within the last 7 days.

Let's break down the command:

  • find: This is the command-line utility in Linux/Unix used to search for files and directories.
  • ${root_path}: It is a variable that represents the starting directory for the search. The actual directory path should be provided in place of ${root_path}.
  • -daystart: This option sets the start time for the search at the beginning of the day. By default, find considers the last 24 hours from the current time as the search window. Using -daystart ensures that the search considers the whole previous day when filtering by mtime.
  • -mtime: It stands for "modification time" and is used to specify a time period for finding files based on their last modification time. In this command, it is used to filter files that were modified within a particular period.
  • -7: It represents the number of days. In this case, it specifies the search window of the last 7 days. -7 means the files modified within the last 7 days will be matched.

So, the overall command searches for files in ${root_path} that were modified within the last 7 days, using the start of the previous day as the beginning of the search window.

This explanation was created by an AI. In most cases those are correct. But please always be careful and never run a command you are not sure if it is safe.
back to the find tool