This syntax
--exclude-dir={dir1,dir2} is expanded by the shell (e.g. Bash), not by grep, into this:
--exclude-dir=dir1 --exclude-dir=dir2 Quoting will prevent the shell from expanding it, so this won't work:
--exclude-dir='{dir1,dir2}' <-- this won't work The patterns used with --exclude-dir are the same kind of patterns described in the man page for the --exclude option:
--exclude=GLOB Skip files whose base name matches GLOB (using wildcard matching). A file-name glob can use *, ?, and [...] as wildcards, and \ to quote a wildcard or backslash character literally. The shell will generally try to expand such a pattern itself, so to avoid this, you should quote it:
--exclude-dir='dir?' --exclude-dir='dir?' You can use the curly braces and quoted exclude patterns together like this:
--exclude-dir={'dir?','dir??'} --exclude-dir={'dir?','dir??'}