Searching for a filename without a certain string

So when you want to search for a file with a filename containing the string xyz from a directory to all depths, you write

sudo find path -name '*xyz*'

How do I find all files without the string xyz?


Add a ! (not) before the expression:

sudo find path ! -name '*xyz*'

To search for files not containing '*xyz*' do:

sudo find path -type f -not -name '*xyz*'

To search for paths (files and directories) not containing '*xyz*' do:

sudo find path -not -path '*xyz*'

To search case-insensitively prepend name or path with i, i.e. -iname or -ipath.