Para obter as linhas que têm , o same_number - > padrão same_number :
grep -E '([[:digit:]]+)[[:blank:]]+->[[:blank:]]+[[:blank:]]'
-
-E
ativa o ERE (expressão regular estendida) -
([[:digit:]]+)
corresponde a um ou mais dígitos e coloca no grupo capturado 1 -
[[:blank:]]+
corresponde a um ou mais espaços brancos horizontais -
->
corresponde literalmente -
refere-se ao primeiro grupo capturado
-
[[:blank:]]
corresponde a um espaço em branco depois disso
Você pode usar a lógica semelhante com outras ferramentas / idiomas populares de processamento de texto, como sed
, awk
, perl
.
Para obter as linhas que não têm o padrão, adicione apenas a opção -v
:
grep -vE '([[:digit:]]+)[[:blank:]]+->[[:blank:]]+[[:blank:]]'
Exemplo:
% cat file.txt
[325194/777232]/var/cache/apt/srcpkgcache.bin: 100% extents: 5 -> 1 [ OK ]
[325195/777232]/var/cache/apt/pkgcache.bin: 100% extents: 4 -> 1 [ OK ]
[325255/777232]/var/cache/man/de/index.db: 100% extents: 2 -> 2 [ OK ]
[325521/777232]/var/log/syslog: 100% extents: 7 -> 1 [ OK ]
[325525/777232]/var/log/lastlog: 100% extents: 2 -> 2 [ OK ]
[325531/777232]/var/log/syslog.1: 100% extents: 5 -> 1 [ OK ]
[325572/777232]/var/log/kern.log: 100% extents: 6 -> 1 [ OK ]
[325589/777232]/var/log/auth.log: 100% extents: 3 -> 1 [ OK ]
[325621/777232]/var/log/faillog: 100% extents: 2 -> 2 [ OK ]
[325625/777232]/var/log/wtmp: 100% extents: 3 -> 1 [ OK ]
[325627/777232]/var/log/kern.log.1: 100% extents: 2 -> 1 [ OK ]
[325644/777232]/var/log/cups/access_log.1: 100% extents: 2 -> 1 [ OK ]
[325810/777232]/var/log/auth.log.1: 100% extents: 2 -> 1 [ OK ]
% grep -E '([[:digit:]]+)[[:blank:]]+->[[:blank:]]+[[:blank:]]' file.txt
[325255/777232]/var/cache/man/de/index.db: 100% extents: 2 -> 2 [ OK ]
[325525/777232]/var/log/lastlog: 100% extents: 2 -> 2 [ OK ]
[325621/777232]/var/log/faillog: 100% extents: 2 -> 2 [ OK ]
% grep -vE '([[:digit:]]+)[[:blank:]]+->[[:blank:]]+[[:blank:]]' file.txt
[325194/777232]/var/cache/apt/srcpkgcache.bin: 100% extents: 5 -> 1 [ OK ]
[325195/777232]/var/cache/apt/pkgcache.bin: 100% extents: 4 -> 1 [ OK ]
[325521/777232]/var/log/syslog: 100% extents: 7 -> 1 [ OK ]
[325531/777232]/var/log/syslog.1: 100% extents: 5 -> 1 [ OK ]
[325572/777232]/var/log/kern.log: 100% extents: 6 -> 1 [ OK ]
[325589/777232]/var/log/auth.log: 100% extents: 3 -> 1 [ OK ]
[325625/777232]/var/log/wtmp: 100% extents: 3 -> 1 [ OK ]
[325627/777232]/var/log/kern.log.1: 100% extents: 2 -> 1 [ OK ]
[325644/777232]/var/log/cups/access_log.1: 100% extents: 2 -> 1 [ OK ]
[325810/777232]/var/log/auth.log.1: 100% extents: 2 -> 1 [ OK ]