22

I want to remove files, more specifically, symbolic links of /usr/include that are newer than 2 JUN 22:27

How can I do this?

2 Answers 2

36

You might want to use find -newermt.

Make sure to review files to be removed first:

find /usr/include -type l -newermt "Jun 2 22:27"

Use -delete to perform actual removes.

find /usr/include -type l -newermt "Jun 2 22:27" -delete
2
  • 1
    Extra info, delete normal files from current directory, example: find . -newermt "Aug 3 5:27" -delete Commented Aug 14, 2017 at 9:59
  • -type l didn't work instead I used -type f Commented Apr 15, 2021 at 6:01
-1

I know the most voted solution may work for alott of people but it did not for me. I had to do it with unix timestamp.

 find . -type f -newermt "$(date -d @1494500000)" -delete

You can convert the timestamp easily with a unix timestamp converter.

1
  • Your answer could be useful but it seams not to be working, it returns: "find: I cannot figure out how to interpret ‘Tue Oct 10 07:00:00 AM +07 2023’ as a date or time"
    – Cory
    Commented Oct 20, 2023 at 3:03

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .