1

I struggle to find a working find command, I hope someone has an idea. Imagine the following structure, where path and path{0..1} exist and they are each mounted from a network storage device:

dir:  /path/userA
link: /path/userB -> /path2/userB

dir: /path1/userA

dir: /path2/userB

My expected result is:

/path/userA
/path1/userA
/path2/userB

The find command should look something like this:

find /path /path{0..9} -maxdepth 1 -type d -name userA -o -name userB

Unfortunately no matter how I tweak and twist the command, either less directories than the expected are shown or still all four... find seems to always follow the symlinks.

I've tried -P , -H, -L options, tried "! -type l" and various combinations, tried -exec addidtions like "-exec test -d {} \; -print", none of them giving the expected result.

Interestingly, if I try to find only the symlink, find still follows it and print the referenced directory:

find /path /path{0..9} -maxdepth 1 -type l -name userA -o -name userB
/path/userB
/path2/userB

Thank you for your help!

Oliver R.
  • 141

0 Answers0