user7128116
user7128116

Reputation:

Meaning of "*" in a regular expression for grep

I'm having trouble finding what the * does in the grep command. I'm following this example:

ian@attic4:~/lpi103-7$ grep "p*" text1
1 apple
2 pear
3 banana

Why does banana appear if p* is there?

Upvotes: 0

Views: 122

Answers (1)

anaotha
anaotha

Reputation: 613

The * symbol means "0 or more times", so the p character does not need to be in the line for it to be matched. If you want the p character to appear at least one time, use + instead.

Upvotes: 1

Related Questions