Searching with grep · Buscando com grep
This page needs a recent browser (with SharedArrayBuffer support). Please update Chrome, Edge, Firefox or Safari to the latest version. · Esta página precisa de um navegador recente (com suporte a SharedArrayBuffer). Por favor, atualize Chrome, Edge, Firefox ou Safari para a versão mais recente.
English
Finding text with grep
grepsearches for a word and prints only the lines that contain it:
- Out of a huge log, you instantly see just the lines that matter.
Português
Encontrando texto com grep
grepbusca por uma palavra e imprime apenas as linhas que a contêm:
grep error log.txt
- De um log enorme, você vê instantaneamente apenas as linhas que importam.
English
Useful options
-iignores case (soErrormatcheserror).-nshows the line number of each match.-vinverts — show lines that do not match.
Português
Opções úteis
-iignora maiúsculas/minúsculas (entãoErrorcorresponde aerror).-nmostra o número da linha de cada correspondência.-vinverte — mostre linhas que não correspondem.
grep -n ok log.txt
English
grep loves pipes
grepshines at the end of a pipe, filtering another command's output:
- "How many error lines?" — filter to errors, then count them. A everyday combo.
Português
grep ama pipes
grepbrilha no final de um pipe, filtrando a saída de outro comando:
cat log.txt | grep error | wc -l
- "Quantas linhas de erro?" — filtre para erros, depois conte-as. Uma combinação cotidiana.
English
Common mistakes
grep pattern filefinds matching lines; add-ito ignore case.- Quote a pattern that has spaces or special characters.
Português
Erros comuns
grep pattern fileencontra linhas correspondentes; adicione-ipara ignorar maiúsculas/minúsculas.- Aspas em um padrão que tem espaços ou caracteres especiais.
Explore · Explorar
grep inside a pipeline · grep dentro de um pipeline
grep filters a stream — feed it the output of another command. · grep filtra um fluxo — alimente-o com a saída de outro comando.
Show only the lines of log.txt that contain error, using grep error log.txt. · Mostre apenas as linhas de log.txt que contêm error, usando grep error log.txt.
How many errors are there? Pipe grep into · em wc -l: grep error log.txt | wc -l. · Quantos erros existem? Pipe grep para wc -l: grep error log.txt | wc -l.