Reputation: 72
I want to get every files that are between 2 date with this format : YYYY-MM-DD HH:mm
I have some constraints too : i can't write files even in /tmp, and i can't use find --newermt
because it's an old server.
I tried to use awk without success :
ls -l --time-style=long-iso | awk '{ if (mktime(gensub ("-", " ", $6) " " gensub (":", " ", $7) " 00") >= mktime(gensub ("-", " ", gensub (":", " ", "2014-08-26 12:30")) " 00") && mktime(gensub ("-", " ", $6) " " gensub (":", " ", $7) " 00") <= mktime(gensub ("-", " ", gensub (":", " ", "2014-08-26 12:30")) " 00")) print $8 }'
Thanks in advance !
Upvotes: 2
Views: 851
Reputation: 246764
I'd see if you can use stat
with an appropriate format. On my (linux) system, print out the file name and the mtime with
stat --format=$'%n\t%y' *
Then, to filter based on the mtime:
stat --format=$'%n\t%y' * |
awk -F"\t" -v from="2014-08-01 00:00" \
-v to="2014-09-01 00:00" 'from <= $NF && $NF <= to {NF--; print}'
Upvotes: 2
Reputation: 7903
Do you mean that there is an old version of 'find' or that you don't have 'find' at all.
If you do have find, but it's an old version, then there's another way than '-newermt':
How to use 'find' to search for files created on a specific date?
The third answer shows how to create two files with the timestamps you require. Then use:
find / -newer /tmp/t1 -and -not -newer /tmp/t2
Upvotes: 2