shell-script-pt
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [shell-script] Contar espaço em um arquivo.


From: Fredi Rolf Bieging
Subject: Re: [shell-script] Contar espaço em um arquivo.
Date: Tue, 8 Sep 2015 12:58:46 -0300

Conta e exibe as linhas com dois campos:

l=$(grep -E '^"[^"]+";"[^"]+"$' /tmp/input.txt); echo -e "$(wc -l <<< "$l") linhas vazias\n"; echo "$l"

2015-09-08 12:23 GMT-03:00 phfbettega address@hidden [shell-script] <address@hidden>:
 

Testando o campo $3 como vazio

awk -F";" '$3 ~ /^$/ {i++; print}; END {print i}'
<<<'"123";"teste";"cachorro"
"124";"teste"
"125";"teste";"cachorro"
"126";"teste"
"127";"teste"
"128";"teste";"cachorro"'
"124";"teste"
"126";"teste"
"127";"teste"
3

On 07-09-2015 18:38, address@hidden [shell-script] wrote:
> Caros Boa Noite,
>
> Tenho um arquivo com seguinte formato:
>
> cat texto.txt
>
> "123";"teste";"cachorro"
> "124";"teste"
> "125";"teste";"cachorro"
> "126";"teste"
> "127";"teste"
> "128";"teste";"cachorro"
>
>
> Estou tentando pegar apenas as linhas da terceira coluna vazia. Então
> pensei em printar a terceira coluna e aplicar a contagem porem não estou
> conseguindo resolver aparti disso. Abaixo segue minha tentativa:
>
>
> cat texto.txt | awk -F ";" '/^ $/{print $3}' | wc -l
>
>
> ele me retorna 0
>
>
> Queria que alem de contar me trouxesse a linha por completo. Por exemplo:
>
>
> 3 linhas vazias
>
>
> "124";"teste"
>
> "126";"teste"
> "127";"teste"
>
>
> Podem me ajudar?
>
>
> Att,
>
>
>
> ----------------------------------------------------------
> Enviado por: address@hidden
> ----------------------------------------------------------



reply via email to

[Prev in Thread] Current Thread [Next in Thread]