Does Grep Regex Work Differently on Mac?

Just trying to figure out basic use of regexes with grep (or egrep) in mac terminal (BSD grep - 2.5.1-FreeBSD).

File to examine (pow.txt) contains the lines :

kiytytytyty

and

blob.mkv

command used is :

grep -E ^[a-z]+\.[a-z]{3}$i pow.txt

match returned is:

kiytytytyty

Obviously this wouldn't match with a PCRE regex. Are regexes interpreted differently on mac ? Or is my syntax wrong ?

8

1 Answer

If you're trying to match blob.mkv, try:

grep -Ei '^[a-z]+\.[a-z]{3}$' pow.txt
2

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Maya Lin-Takahashi

Maya Lin-Takahashi

Consumer Tech & Gadget Reviewer

Maya is a hardware enthusiast who tests and reviews smart home devices, smartphones, wearables, and audio gear. She focuses on practical consumer value and build quality.

Share this article
Twitter Facebook Pinterest