Find the files that have been changed in last 24 hours
To find all files modified in the last 24 hours (last full day) in a particular specific directory and its sub-directories:
find /directory_path -mtime -1 -ls
Should be to your liking
The -
before 1
is important - it means anything changed one day or less ago.
A +
before 1
would instead mean anything changed at least one day ago, while having nothing before the 1
would have meant it was changed exacted one day ago, no more, no less.
file created yesterday or today
A better way to do this is
for file in $(find ./ABS* -mtime -2 ! -name *.bz2); do
MY WORK
done
The -mtime -x flag means any files modified fewer than x days ago.
How to use 'find' to search for files created on a specific date?
As pointed out by Max, you can't, but checking files modified or accessed is not all that hard. I wrote a tutorial about this, as late as today. The essence of which is to use -newerXY
and ! -newerXY
:
Example: To find all files modified on the 7th of June, 2007:
$ find . -type f -newermt 2007-06-07 ! -newermt 2007-06-08
To find all files accessed on the 29th of september, 2008:
$ find . -type f -newerat 2008-09-29 ! -newerat 2008-09-30
Or, files which had their permission changed on the same day:
$ find . -type f -newerct 2008-09-29 ! -newerct 2008-09-30
If you don't change permissions on the file, 'c' would normally correspond to the creation date, though.
list only last 24 hours created files in unix
To find all files created in the last 24 hours in a particular specific directory and its sub-directories:
find /users/c_t2/ws/ -ctime -1 -ls
If you want to find all files modified:
find /users/c_t2/ws/ -mtime -1 -ls
How to find file accessed/created just few minutes ago
Simply specify whether you want the time to be greater, smaller, or equal to the time you want, using, respectively:
find . -cmin +<time>
find . -cmin -<time>
find . -cmin <time>
In your case, for example, the files with last edition in a maximum of 5 minutes, are given by:
find . -cmin -5
Related Topics
How to Add Date String to Each Line of a Continuously Written Log File
How Does a Linux Socket Buffer Overflow
Why Is It That Utf-8 Encoding Is Used When Interacting with a Unix/Linux Environment
Looping a Video with Gstreamer and Gst-Launch
Linux Debian Crontab Job Not Executed
Read a Single Sector from a Disk
Why Does a Syscall Clobber Rcx and R11
How to Make R Read My Environmental Variables
Sort Logfile by Timestamp on Linux Command Line
Syntax Error: End of File Unexpected (Expecting "Then")
Why Does C99 Complain About Storage Sizes
Sys_Execve System Call from Assembly
Combine a Shell Script and a Zip File into a Single Executable for Deployment
Getting Disconnection Notification Using Tcp Keep-Alive on Write Blocked Socket
Why Does %Rbp Point to Nothing