My computer is running macOS 10.12.3 and I am using the system-installed grep utility with version 2.5.1-FreeBSD.
These are the outputs I get when testing various regexes:
But if I run these using GNU grep (version 2.25) I get the following:
GNU’s grep looks correct to me and BSD’s is incorrect, no? Why do they differ? I don’t understand why BSD’s grep is matching the “a” when the regex specifies that it must follow the beginning of the line.
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
I think this might be a bug in FreeBSD’s grep. There’s a bug report with similar issues.
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

