Skip to main content
Became Hot Network Question
nothing to do with bash, nothing particularly linux
Link
ilkkachu
  • 147.8k
  • 16
  • 268
  • 441

Linux bash exclude directory from find command

edited tags
Link
Kusalananda
  • 355.8k
  • 42
  • 735
  • 1.1k
Source Link

Linux bash exclude directory from find command

I'm trying to get the hang of excluding a directory while searching for a particular file.

I'm on WSL2 so want to exclude the /mnt/ folder so I don't end up searching my entire file-system.

I can do:

find . -path './mnt' -prune -o -print

which prints all directories and files EXCLUDING the /mnt/ folder, but I'm struggling to combine this with the correct syntax to find a specific file, e.g.

find -name example.txt