How to find files with square brackets in the name

find, linux, regex

Solution

No matching square brackets is not a problem. Problem is matching the file's path. Remember find's output starts with `./` for the current path.

So this regex in your find command will work for you:

find . -iregex '\./\[abc\].*test.*'

Problem

I'm trying to find some files with square brackets, but I can't seem to get it to work. My files are named are this: [ABC] test file.txt Regexp I'm trying: ``` find . -iregex '\[abc\].*test.*' ``` That just doesn't seem to work for some reason. If i replace it with - ``` find . -iregex '.*abc.*test.*' ``` -it works fine. So the problem is with the square brackets. Any ideas?

Original source