0

Inside the /tmp I want to find files older than 180 day, but I also want to exclude some folders from the search like ./vboxdrv-Module.symvers. How can I perform the task with find?

3

This syntax will do what you want:

find -not -newermt 2016-11-10 -not -path "./vboxdrv-Module.symvers/*"

Change with whatever settings you want.

Add as many -not -path you want after each other. Ie.

find -not -newermt 2016-11-10 -not -path "./folder1/*" -not -path "./folder2/*"

Or if you want to do it from another folder:

find /tmp/ -not -newermt 2016-11-10 -not -path "/tmp/folder1/*" -not -path "/tmp/folder2/*"
4
  • Good answer, but your examples should show what the questioner wants, eg -not -newermt 2016-11-10, instead of your -name clause. – AFH May 10 '17 at 10:59
  • You're right. I was being too lazy. I'll update accordingly. – Mikael Kjær May 10 '17 at 11:03
  • Is the a POSIX variant? I need it cause I've got to perform the same action on AIX – OverMorrow May 10 '17 at 11:15
  • I'm unsure about the time in POSIX, but it sounds like you have that. If that's the case just exchange -not with !. Ie. ! -path "/tmp/folder1/*" – Mikael Kjær May 11 '17 at 8:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.