One way with bash, files in between 20:00 and 22:00
#!/usr/bin/env bash
for f in /folder/x/*.bak; do
var=$(date -r "$f" '+%H:%M')
if [[ $var > '20:00' && $var < '22:00' ]]; then
echo "$f"
fi
done
The above code should match your files.
That date syntax works on both GNU and BSD date(1)
- The above code should match your files.
- Just change to
[[ $var < '20:15' ]]If that's just what you're after. - That
datesyntax works on bothGNUandBSDdate(1)
EDIT: Updated answer