I am trying to make GNU find exclude entries UP TO the specified file name.
Take this sample tree:
./foo
./foo/another.txt
./foo/bar
./foo/bar/world
./foo/bar/world/test.txt
./foo/bar/world/hello.txt
(There would be a bunch of other files in the world
and other directories as well, that is why I am not simply searching for hello.txt
).
I want match everything but 'test.txt' and its parent directories.
The output should simply be foo/bar/world/hello.txt
.
This command produces the right results, but it is pretty messy, and would produce the wrong results if there were several directories with the same names:
find * ! -name test.txt -a ! -name foo -a ! -name bar -a ! -name world