I try to do this command on my Mac OS X 10.9 Terminal:
find / -type f -regextype posix-extended -regex "(.*A.*a.*.*)|(.*a.*A.*.*)" -exec tail -n 3 '{}' \;
But the Bash v 3.2 response is:
find: -regextype: unknown primary or operator
I have made a deeply search on Terminal manpages:
man find
man regex
etc...
But I find nothing. Does the Mac OS X Bash v3.2 should to be updated? It seems that the option "-regextype" is not included in the "find".
How can I fix it?
p.s. The command works perfectly on Ubuntu Linux 14.
The simplest answer to your question is that on OS X you need to use the -E
option instead of -regextype posix-extended
ie:
find / -type f -regextype posix-extended -regex "(.*A.a..*)|(.*a.A..*)" -exec tail -n 3 '{}' \;
becomes:
find -E / -type f -regex "(.*A.a..*)|(.*a.A..*)" -exec tail -n 3 '{}' \;
and aside from the -exec tail
command that complains, the above works on my 10.10 installation.
This is actually covered by the first entry of the man page:
The options are as follows:
-E Interpret regular expressions followed by -regex and -iregex primaries as extended (modern) regular expressions rather than basic
regular expressions (BRE's). The re_format(7) manual page fully describes both formats.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With