How to find all files modified from midnight (i.e. from midnight (00:00:00)) of current date?

Hi there!

I was wondering if someone could help me with the following:

I'm trying to find all files within a directory which have been modified since midnight of the current date.

Any help would be appreciated.

Thank you kindly.

Use touch to set a file with the desired start time and then use:

find directory_name -newer start_time_file ...

to list your desired files.

Hi there,

Thank you for your reply, but could you please tell me how I would go about not hard-coding a specific filename, rather hard coding a specific time (00:00:00)?

Thank you.

I did!

Did you look at the touch man page to see how to create a file with a given timestamp? Did you look at the find man page to see how the -newer file primitive can be used to find files newer than a given timestamp?

This is the Shell Programming And Scripting forum (not the UNIX for Dummies Questions & Answers forum), so I assumed that you just needed a couple of pointers in the right direction.

Try:

touch -t $(date +%Y%M%D0000) start_time_file
find directory_pathname -newer start_time_file

----------------
See correction in later post. The date format string is wrong.

1 Like

Hiya Don,

Thanks for the help :slight_smile:

Oops. That date command should have used a different format string.

Try:

touch -t $(date +%Y%m%d0000) start_time_file
find directory_pathname -newer start_time_file

Yeah I picked up on that, cheers!