1

I'm trying to find files in some dir and ignore some path.

cd /some/dir && find . -type f ! -path ./media doesn't work. Where is a mistake?

Any directory with the same name in subdirs shouldn't be ignored. E.g./some/media/.

P.S. Also mask ./media/* does not work too.

P.P.S Yeah, I know I can use grep like grep -vE "^(\./dir1|\./dir2)". Any chance to use find only?

Kirby
  • 2,847
  • 2
  • 32
  • 42
  • `! -path ./media ` is only false for the exact directory (or file) `./media`, it's still true for anything in that directory (e.g. `./media/somefile`). You want `find . -type f ! -path ./media ! -path './media/*'` or `find . -path ./media -prune -o -type f -print` (this will actually stop traversing the directory rather than just not printing it, though both should produce the same output) – Reinstate Monica Please May 25 '15 at 04:09

1 Answers1

1

You can use the -regex option:

find -type f ! -regex '.*/media/.*'