0

Can someone explain what find -path means?

I tried looking at the man page, but I do not understand why it works the way it does with the script I wrote.

find ! -path . -type d -printf '%T@ %P\n' | sort -nr | head -n3 | awk '{print $2}'

This returns to me the last three modified directories in the current folder Im in. However, when I remove the -path . it only returns files to me, instead of folders. It's almost as if -type d is ignored.

1

If you remove the -path . but keep the ! at the start, then -type d is not ignored, your condition is ! -type d, which means "not directory". SO you get what you ask for.

  • Ah so, ! -path . is simply ignoring the current directory i.e. .? – walksignison Aug 19 '18 at 13:06
  • Yes, exactly, ignore .. – RalfFriedl Aug 19 '18 at 13:06
0

The command you are trying will ignore the current folder with the argument ! -path .. Since you removed only -path . the not-operator ! will apply to the succeeding argument, -type d.

The result is that find will ignore all directories in the find path.

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.