rw-r-r- 1 daygeek daygeek 157 Jul 29 18:29 service1.sh rw-r-r- 1 daygeek daygeek 776 Jun 14 12:00 memory-monitor.sh rw-r-r- 1 daygeek daygeek 830 Jun 14 11:54 process.sh rw-r-r- 1 daygeek daygeek 616 Jun 2 13:25 cpu-alert2.sh This can be done by using the ls command with some options as shown below, which sorts the files and folders in reverse order based on the conversion time. -mtime 10: Use this format to find all files that were modified EXACTLY 10 days ago.ġ) Sorting files & folders based on conversion time.-mtime -10: It will find all files that were modified in the last 10 days.-mtime +10: This will find all files that were modified 10 days ago.See the format below for a better understanding. Use “-mtime n” command to return a list of files that were last modified “ n” hours ago. We can use numerical arguments with ‘mtime’. The common syntax is as follows: stat # stat /home/daygeek/shell-script/remote-backup.shįile: /home/daygeek/shell-script/remote-backup.sh It can be easily seen using ‘stat’ command, which displays all three timestamps of a file. ctime/cmin: The last time the file’s attribute was modified.mtime/mmin: The last time the file’s contents was modified.atime/amin: The last time the file was accessed by some command or application.Read the below explanation for better understanding about timestamp. mtime: modify time or Last modification time.In Linux, a file contains three timestamps, which are updated when a file is accessed or modified or replaced. In this article, we have included 13 examples for locating files based on timestamp and I hope this article will meet your needs.
#DOS COMMAND TO FIND FILES BY DATE HOW TO#
Please refer to our previous article on how to find a directory size in Linux. The find command is used to search or locate files based on various criteria such as timestamp, file type and file permissions in Linux. Use these commands at your own risk.If you are working on thousands of files a day and want to find a list of files that have been modified recently in a directory for certain purposes, this can be done easily using the find command. 5: Delete files in the current folder which were updated one month ago forfiles /D -30 "cmd /C del cautious while running these commands, verify that you are deleting the right set of files, otherwise the data lost may not be recoverable. This command looks processes files in subfolders also, ‘/S’ can be removed to perform this only for the files in the current folder. The command for this would be as below forfiles /S /D -3 /C "cmd /c move D \archiveDir" Let’s say we want to move the files which are not modified 3 days ago to another folder(D:\archiveDir). The syntax of the command is forfiles /D date /C "cmd /c command 4: Move files to another folder based on modification time This can be used to run commands on the files set returned by the command. To find files modified before 20th August 2013: forfiles /P directory /S /D - Execute commands on the files selectedįorfiles has an equivalent functionality similar to -exec option with linux find command. To find files modified after 1st August 2013, we can run the below command forfiles /P directory /S /D + Find files that were last modified 1 month back forfiles /P directory /S /D -30 3. D:\>forfiles /S /D -3ĮRROR: No files found with the specified search criteria. If there are no files meeting the condition, the command prints the following message. This option says to search for the files modified after n days from today’s date. Please note that /D +(number of days) is practically not useful. Specifying /S makes it search for such files recursively in all subfolders. This command search for files created in the folder(specified with /P) in the last 7 days.