how do I check in bash whether a file was created more than x time ago?
Only for modification time
if test `find "text.txt" -mmin +120`
then
echo old enough
fi
You can use -cmin
for change or -amin
for access time. As others pointed I don’t think you can track creation time.
I always liked using date -r /the/file +%s
to find its age.
You can also do touch --date '2015-10-10 9:55' /tmp/file
to get extremely fine-grained time on an arbitrary date/time.