Problems extracting some information

Hi there!

Well, I'm writing a script to obtain certain information about files. Specifically, I want to get the information about those files which last access were in the last 24 hours, so I'm doing something like this:

find <directory_name> -atime -1 -printf '%f %a\n'

I would also like to add some extra information to this result: I would like to obtain the date and time of the last modification of these files if that is also during the last 24 hours, so that I might use '%t' anywhere. The problem is that not all files were also modified during this time. How could I implement this condition in the code? I want a result like this:

<file_name1> <last_access_time1>
<file_name2> <last_access_time2> <last_modification_time2>
<file_name3> <last_access_time3>
<file_name4> <last_access_time4>
<file_name5> <last_access_time5> <last_modification_time5>
      ...               ...                        ...

where files 2 and 5 were modified within the last 24 hours. Is there a way to insert conditions to fulfill before printing the results? Or anything equivalent to get this behaviour?

Thanks in advance.
Regards.

find . -name "*" -type f -mtime -1  -exec stat -c "{} %x %y" {} \;

---------- Post updated at 01:17 PM ---------- Previous update was at 01:15 PM ----------

And if you want those angles

find . -name "*" -type f -mtime -1  -exec stat -c "<{}> <%x> <%y>" {} \;

Yes, that shows me the last modification time and last access time, but only for the files accessed and modified within the last 24 hours. I would be also interested in those files accessed within the last 24 hours, but not modified...

Thank you for your answer anyway :slight_smile:

 find . -name "*" -type f -atime -1 -a -mtime +1 -exec stat -c "<{}> <%x> <%y>" {} \;

Accessed in last 24 hours but not modified in last 24 hours

Thank you so much for your help, msabhi :wink: