It would be easier for everyone if the text used were posted, instead of an image.
To help everyone, here is the file (found parts of somewhere in the internet):
$ cat HBB.fna
>NM_000518.5 Homo sapiens hemoglobin subunit beta (HBB), mRNA
ACATTTGCTTCTGACACAACTGTGTTCACTAGCAACCTCAAACAGACACCATGGTGCATCTGACTCCTGA
GGAGAAGTCTGCCGTTACTGCCCTGTGGGGCAAGGTGAACGTGGATGAAGTTGGTGGTGAGGCCCTGGGC
AGGCTGCTGGTGGTCTACCCTTGGACCCAGAGGTTCTTTGAGTCCTTTGGGGATCTGTCCACTCCTGATG
CTGTTATGGGCAACCCTAAGGTGAAGGCTCATGGCAAGAAAGTGCTCGGTGCCTTTAGTGATGGCCTGGC
TCACCTGGACAACCTCAAGGGCACCTTTGCCACACTGAGTGAGCTGCACTGTGACAAGCTGCACGTGGAT
CCTGAGAACTTCAGGCTCCTGGGCAACGTGCTGGTCTGTGTGCTGGCCCATCACTTTGGCAAAGAATTCA
CCCCACCAGTGCAGGCTGCCTATCAGAAAGTGGTGGCTGGTGTGGCTAATGCCCTGGCCCACAAGTATCA
CTAAGCTCGCTTTCTTGCTGTCCAATTTCTATTAAAGGTTCCTTTGTTCCCTAAGTCCAACTACTAAACT
GGGGGATATTATGAAGGGCCTTGAGCATCTGGATTCTGCCTAATAAAAAACATTTATTTTCATTGCAA
Then, your question:
I'm trying to describe how dot (.) works in a regular expression.
There is no simple way to match a newline in grep with a dot
(.
). It can be hinted by what we see:

The matched characters have to be a multiple of 3 dots, that is 69 and that leave just 1 that doesn't match the dots. That's why there is a non-colored last character in most of the lines.
But even if we were to use 71 dots (because 71 is prime there is no other number to match it). That's the 70 characters we see in each line plus an ending newline.

Because the .
dot
can not match a newline. it is removed before each line is processed and reattached after the line has been processed. There is no newline to match in any case.
Even if we were to use the non-standard -z
option (which process the whole text input as one continuous block and therefore allows newlines to remain in the matched text, the newline turns out to be a non-printing character, much like an space
or a tab
or some other whitespace
, the terminal can not print them.

So, we need to transform the newlines (matched or not, but present on the output) to something visible (lets use a =
, similar to the $
encoding of vi or sed -n l
) and lets add an additional newline so that lines don't collapse into a continuous (without format) stream of characters. That is easy to do with sed -z 's/\n/=\n'
or some other similar editor:

So, There is no way to match a newline with a dot
(.
) in grep, not even in default pcre. But we can make the newlines appear and be seen by intelligently editing the grep output.
Hope that solves your need.
grep
. It implicitly considers only the part of the line before the newline, and doesn't try to match the regex pattern against it. So it never matches, there's no question about it, so no reason to show it. (And, well, grep would print the trailing newline even if it isn't there, e.g.printf 'foo' |grep .
printsfoo<newline>
in all systems I have.)grep
tocat -A
?sed 's/\$$/\\n/'
di differentiate a EOL$
from other instances.