Want to find older directories than directory on which I'm using -not -newer statement (it's a part of bigger FIND statement). But can't figure it out how to "protect" this directory from beeing marked as older than itself.

For example

find /home/user/data/ -not -newer $variable

$variable contains path to this directory, from which I'm trying to find older directories.


I'm not exactly sure this is what you're asking, but perhaps just exclude the directory explicitly?

find /home/user/data/ -not -path $variable -not -newer $variable

This works if you want to exclude a particular location.

$ mkdir -p a/b
$ find a -not -newer a
$ find a -not -path a -not -newer a
  • I don't wanna sound stupid, but is there such commend as "wholename" ? – harcotlupus Nov 8 '17 at 19:22
  • Depends on which find you are using. Your command used -not, so I assumed -wholename was available as well. -path would be more portable. I'll change it. – BowlOfRed Nov 8 '17 at 19:24
  • My bad then, but still it's not working, was trying to use -not -path $variable but with same effect. – harcotlupus Nov 8 '17 at 19:26
  • Can you give more information, like the exact directory name that is appearing that you don't want and the value of $variable? – BowlOfRed Nov 8 '17 at 19:26

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.