If your version of find
has a -regex
primary, you can use that. Unfortunately, it's nonstandard, and you need extended regex syntax which is even less standard. With GNU find
, you use -regextype
to set the regular expression syntax (and it goes after the directory to search), so it'd be something like this:
find . -regextype egrep '!' -regex '.*[.](h|cpp|dll)'
With BSD (/macOS) find
, you'd use the -E
option before the directory to search, so it looks like this:
find -E . '!' -regex '.*[.](h|cpp|dll)'
Note that this is a regular expression, not a glob (wildcard) pattern, so you have to use .*
to match any string, and escape or bracket the .
so it won't be treated as "match any single character". Also, the regex pattern is matched against the entire path, not just the filename (doesn't matter here, but it would would other patterns).
find . ! -name '*.h','*.cpp','*.dll'
and lemme know if it works. I don't ever use the find command so I'm not 100% sure if that will work or not.find . ! -name '*.h' ! -name '*.cpp' ! -name '*.dll
alias mycommand="find . ! -name '.h' ! -name '.cpp' ! -name '*.dll",if you want to persist between shell session add this to your .bashrc, so next time you want to run this just type mycommand so sleek