Programmer
Programmer

Reputation: 6753

Does grep on AIX support the?

I am trying to use the following grep command

grep "Fred\(eric\)\? Smith" names.txt

where names.txt contains Fred Smith and Frederic Smith. However, grep only matches Frederic Smith. So, is ? supported in grep where ? refers to the character occurring 0 or 1 time.

Upvotes: 0

Views: 199

Answers (1)

Shiplu Mokaddim
Shiplu Mokaddim

Reputation: 57650

AIX uses UNIX grep. So it supports basic RE. But I suggest you use extended RE with -E option. Then you dont have escape those special characters.

grep -E "Fred(eric)? Smith" names.txt

Upvotes: 1

Related Questions