What does the + symbol mean in the following grep regular expression: <code> grep ‘^d[aei]\+d$’ /usr/share/dict/words </code>

What does the + symbol mean in the following grep regular expression:

grep ‘^d[aei]\+d$’ /usr/share/dict/words

What does the + symbol mean in the following grep regular expression:

grep ‘^d[aei]\+d$’ /usr/share/dict/words

A.
Match the preceding character set ([aei]) one or more times.

B.
Match the preceding character set ([aei]) zero or more times.

C.
Match the preceding character set ([aei]) zero or one times.

D.
Match a literal + symbol.

Explanation:
The answer should be “Match a literal + symbol” because there is a backslash symbol before the
plus, so it should match a literal +.



Leave a Reply 3

Your email address will not be published. Required fields are marked *


Busindre

Busindre

The correct answer is A.

echo -n “daeiiiiad” | grep –color “^d[aei]\+d$”
daeiiiiad

echo -n “da+d” | grep –color “^d[aei]\+d$”

root:/home/muza $ echo -n “da+d” | grep –color “^d[aei]+d$”
da+d

Raza

Raza

Yes it’s “A”

akizd

akizd

In basic regular expressions the meta-characters ?, +, {, |, (, and ) lose their special meaning; instead use the backslashed versions \?, \+, \{, \|, \(, and \).