To find files by date and list files modified on a specific date on a Linux system, you can use the find
command with the -mtime
and -newermt
options.
The -mtime
option allows you to search for files based on the number of days since they were last modified. For example, to find files modified within the last 7 days, you can use the following command:
find . -mtime -7
This will search for files modified within the last 7 days (including today) in the current directory and all subdirectories.
The -newermt
option allows you to search for files based on a specific date. For example, to find files modified on July 1, 2021, you can use the following command:
find . -newermt "2021-07-01 00:00:00"
This will search for files modified on or after July 1, 2021 in the current directory and all subdirectories.
You can combine these options with other options, such as -type
to search for specific file types or -name
to search for files with a specific name pattern.
For example, to find all PDF files modified within the last 7 days, you can use the following command:
find . -mtime -7 -type f -name "*.pdf"
This will search for PDF files modified within the last 7 days in the current directory and all subdirectories.
Keep in mind that the find
command is a powerful tool that can be used to search for files and directories based on a wide range of criteria. You can use the various options available with the find
command to fine-tune your search and find files based on date and other attributes.