Why in the following:
echo this is a line. | grep -o -E "[a-z]+\."
The result is line. and not this is a line.?
this is a line.
There is no word boundary or any other restriction on the regex.
[a-z] only matches the characters a to z. they do not match the space character. when you want to match also the space character you have to explicitly say so: [a-z ].
[a-z] only matches the characters a to z
this is a line
The -o option instructs grep to limit the output to just that part of the line which matches the pattern.
Rerun the command without -o and the result will indeed be
Sign up using Google
Sign up using Facebook
Sign up using Stack Exchange
1 year ago