Find files created on specific date

Please, I am trying to list files created on specific date as below:

find . -type f -newermt 2020-04-25

But it prints all files created on 25 April and later whilst I need files created on 25 only.

Could you please advise?

Thanks

find . -type f -newermt 2020-04-25 | grep 04-25

:sunglasses:

1 Like
find . -type f -newermt 2020-04-25 \! -newermt 2020-04-26
1 Like

Your question asks when files were "created". Do you mean that?

Traditional unix/linux filesystems do not store file creation timestamps so please post what type of filesystem and what kernel (distro and version) you are running. This question is impossible to answer until you provide us with your environment.

Later filesystems e.g. ZFS, HSF and Ext4 do provide file creation timestamps which kernels like Fedora and OSX do support but many kernels still do not support file creation timestamps even if the filesystem they are using do.

File modification time queried with "newermt" is not the same as file creation time.

Ref:

https://stuff-things.net/2015/06/17/unix-timestamps-explained/

This one worked fine !

But the point here that date is a variable as it depends on $DAY
So, I have to insert as following:
find . -type f -newermt 2020-$DAY \! -newermt 2020-**$DAY+1**

So, how I can insert $DAY+1 ?

Thanks in advance !

Here is the version please:

Linux localhost.localdomain 4.14.35-1902.10.4.1.el7uek.x86_64 #2 SMP Mon Jan 27 14:13:38 PST 2020 x86_64 x86_64 x86_64 GNU/Linux

So are you running Oracle Linux? With a ZFS filesystem?

If so, file creation timestamps are probably supported.

Look at your find man page:

man find | more

and look to see what switches are supported. Look particularly for 'crtime' (file creation timestamp). If that is implemented then you can search for files created on a specific day.

It's NOT about a real file creation (birth) date. The mtimes work, see post#1, it's about limiting them to a specific day.

@MadeInGermany........Are you sure? The OP said finding files created on a specific day. That's not the same as file that existed before that day but happened to be modified on that day. 'created' is not the same as 'modified' in my book. Perhaps in post#1 s/he didn't mean 'created' and I did ask if that's what was really meant.

Try something like:

dd=2020-04-25
dd2=$(date -d "${dd} +1 day" +%Y-%m-%d)
find . -type f -newermt "$dd" \! -newermt "$dd2"
1 Like

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.