Linux find files in dir with modified date from date to date

TheHiveMind

Banned
Joined
Jul 25, 2008
Messages
5,073
Reaction score
4
Location
The Big Wide World
as the title says.. I need a command for linux that will find files in a dir with modified date from "date" to "date".

the directory is full of files. Far too big to actually list them conventionally "ls". I was playing around with "file . -newer filename" to get all files that are newer than a certain file I specify. Is there a way I can specify that they must be newer than a file, and older than a different file?
Im trying to get files that are created between two date times in that directory. If possible, I kinda want it to return, not only the file names, but also the modified date. I trust nothing.

Thanks
 
Last edited:
From what date to what date? If it's, for example, files in the same month:
ls -l | grep "2008-06"

You can use grep for more complicated regex's if you want. Alternatively, you can use sed
 
From what date to what date? If it's, for example, files in the same month:
ls -l | grep "2008-06"

You can use grep for more complicated regex's if you want. Alternatively, you can use sed

Won't work if the problem is too many files.

Something like:
find Source/temp -type f -name "*November*" -exec cp {\} Dest/ \;

or use xargs
 
Thanks for going through this find command tutorial.. & here's the solution for your query..
find /data/ -cnewer temp -and ! -cnewer ntemp

prior to that..
touch temp -t 200604141130
touch ntemp -t 200604261630
So create 2 files with the dates you want to look in for, then run the find command.
 
thanks

anyway that I can return the modified datetime aswell as the filename?
Filenames do not contain dates btw. Thats why im using -newer arg to check based on modified times
 
All linux commands are pretty powerfull, the only problem is that we rarely use its advanced features (of any particular command).

Same for ls:
ls -utl
This will sort everything in "time" mode (-u with -lt: sort by, and show, access time with -l: show access time and sort by name otherwise: sort by access time), the only problem is that I have not figured out yet how to define a range with ls, although it is possible from the man pages.

I'm just waiting for something to download and then I'll go intl to see what I can find.
 
I found a similar forum thread, but:
http://www.unix.com/unix-dummies-qu...t-file-names-certain-date-range-using-ls.html

"Thank you for visiting UNIX.COM. Our server is too busy at the moment. We are upgrading the server soon and this problem will be resolved. Until then, please try back in a few minutes. Thank you for your patience. We are upgrading soon!"

How's that for wanting to bash your head against a rock!

EDIT:
Okay, got a quick and dirty hack to do this:
Code:
find /home/xxx/distfiles/ -cnewer xmlrpc-c-1.14.07.tar.bz2
-cnewer file
File’s status was last changed more recently than file was modified. If file is a symbolic link and the -H option or the -L option is in effect, the status-change time of the file it points to is always used.

-anewer file
File was last accessed more recently than file was modified. If file is a symbolic link and the -H option or the -L option is in effect, the access time of the file it points to is always used.
etc.

man find to further your needs.

This is a dirty one, not elegant but with a bit it will do the job.

EDIT 2:
Quote:
Thanks for going through this find command tutorial.. & here's the solution for your query..
find /data/ -cnewer temp -and ! -cnewer ntemp

prior to that..
touch temp -t 200604141130
touch ntemp -t 200604261630
So create 2 files with the dates you want to look in for, then run the find command.
Did not see this, sorry.
:(
 
Last edited:
Top
Sign up to the MyBroadband newsletter
X