April 2018
Beginner
284 pages
7h 3m
English
The curly braces define the number of existence of the preceding character or character class:
$ echo "tt" | awk '/to{1}t/{print $0}'$ echo "tot" | awk '/to{1}t/{print $0}'$ echo "toot" | awk '/to{1}t/{print $0}'$ echo "tt" | sed -r -n '/to{1}t/p'$ echo "tot" | sed -r -n '/to{1}t/p'$ echo "toot" | sed -r -n '/to{1}t/p'

The third example doesn't contain any matches because the o character exists two times. So, what if you want to specify a more flexible number?
You can specify a range inside the curly braces:
$ echo "toot" | awk '/to{1,2}t/{print $0}'$ echo "toot" | sed -r -n '/to{1,2}t/p'
Here, we match the o character if it ...