From a138f8858a28213b1603378c95a5e835e49b600c Mon Sep 17 00:00:00 2001 From: Felipe Soares Barbosa Silveira Date: Wed, 8 Nov 2023 09:46:09 -0300 Subject: [PATCH] Create grep.md --- grep.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 grep.md diff --git a/grep.md b/grep.md new file mode 100644 index 0000000..c81d833 --- /dev/null +++ b/grep.md @@ -0,0 +1,17 @@ +grep -v '^$' file.txt | sort | uniq +# Grep + +## Contar quantidade de linhas de um arquivo que contenham essa string +```bash +grep -o 'prod\.ERROR.*Too many connections' laravel-2023-10-31.log | wc -l +``` + +## Abrir no less as linhas que contenham essa string +```bash +grep -o 'prod\.ERROR.*' laravel-2023-11-01.log | less +``` + +## Gerar um arquivo de texto com as linhas Ășnicas e ordenadas alfanumericamente +```bash +grep -o 'prod\.ERROR.*' laravel-2023-11-01.log | uniq | sort > teste.log +```