Positive closure
The positive closure or plus (+) means that the item immediately preceded by + is matched one or more times. For example, the ca+t would match cat and caat, whereas ca*t would match all three, as follows:
$ echo -e "cat\n
ct\n
caat\n
cbt" | awk '/ca+t/'
The output on execution of the preceding code is as follows:
cat
caat
A summary of positive closure (+) is as follows:
Pattern |
Matches |
A+ |
Matches the single A, AA, or AAA, and so on |
AB+C |
Matches ABC, ABBC, or ABBBC, and so on |
[0-9]+ |
Matches one or more numbers |
[0-9][0-9]+ |
Matches two or more numbers |
^A+ |
Matches any line beginning with one or more A letters |
^A\+ |
Matches any line starting with A+ |
^AA+ |
Matches any line starting with two AA as AA or AAA, and so on |
AB+C |
Matches ABC, ABBC, or ABBBC, and so on |
(AB)+C |
Matches ABC, ABABC, ABABABC, and so on |
[A-Z]+ |
Matches any string of one or more uppercase letters |