March 2018
Beginner to intermediate
416 pages
9h 24m
English
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\nct\ncaat\ncbt" | awk '/ca+t/'
The output on execution of the preceding code is as follows:
catcaat
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 ... |
Read now
Unlock full access