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 !
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}'