Bash newbie here. The task is to find all files in a (rather large) directory whose modification date falls between various pairs of times. These times are specified as Unix timestamps in a CSV file:
1483743420,1483747020
1484348640,1484352240
1484953920,1484957520
1485559200,1485562800
1486164480,1486168080
1486769820,1486773420
My early thought was to use find
and awk
:
find "$PROJECT_DIR" -type f \
-newermt "$(awk -F "","" '{print $1}' "$DATE_CSV")" -not \
-newermt "$(awk -F "","" '{print $2}' "$DATE_CSV")"
find
doesn't seem to recognize this date format. More pressingly, this code only sends the first date to find
, and the rest are printed:
$ bash datefind.sh
find: Can't parse date/time: 1483743420
1484348640
1484953920
1485559200
1486164480
1486769820
Is there a way to do this with a single find command? Or should I be trying something else?