Esse resultado é porque . corresponde a qualquer caractere único
-
Em página > EXPRESSÕES REGULARES:
The fundamental building blocks are the regular expressions that match a single character. Most characters, including all letters and digits, are regular expressions that match themselves. Any meta-character with special meaning may be quoted by preceding it with a backslash.
The period . matches any single character.
Portanto,
.é necessário para escapar com\$ cat file | grep '\.' 7.8Observe que aqui
\.deve ser citado com'. -
Outra maneira é usar a opção
-F, --fixed-stringscomgrepou usarfgrep.-F, --fixed-strings Interpret PATTERN as a list of fixed strings, separated by newlines, any of which is to be matched.Exemplo:
$ cat file | grep -F . 7.8$ cat file | fgrep . 7.8 -
Outra alternativa é usar a expressão de colchetes com uma cadeia de caracteres que deve ser correspondida dentro de
[e]:$ cat file | grep '[.]' 7.8