Den 08.11.10 12.50, skrev Harald Hanche-Olsen:
+ Andre Massing<[email protected]>:
I am struggling with the find command, trying to find all files ending
with .h or .cpp in a certain directory.
On my former linux machine the following worked as intended:
find ./ -regextype grep -regex '.*\.\(\(h\)\|\(cpp\)'
but Apple's find command does neither know the regextype option nor
does it work as expected if I omit it. I tried already different kind
of
grouping and escaping but without success. Has anybody an idea how I
can get find to work as intended?
Have you checked the man page for Apple's find, notably the -E flag
(and the resulting reference to re_format(7))?
Ah, thanks for that. I had already studied the re_format man page, but
did not stumble about the -E option in the find help.
So it worked with
find -E ./ -regex ".*\.(h|cpp)"
Anyhow, for your particular need, using regexps is overkill.
find . \( -name '*.h' -o -name '*.cpp' \)
will work, and is easier both to type and to read.
That is true, I have a slightly more complex case here, so I stripped it
down a bit.
But anyway, thank you very much for your help!
Cheers,
Andre
You may skip \( and \) in the above usage, but they are needed if you
follow the search term with -print0 or stuff like that.
- Harald
_______________________________________________
macports-users mailing list
[email protected]
http://lists.macosforge.org/mailman/listinfo.cgi/macports-users