[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Identificar a maior linha de um arquivo
From: |
Sérgio |
Subject: |
Re: Identificar a maior linha de um arquivo |
Date: |
Mon, 31 Oct 2011 19:24:29 -0000 |
User-agent: |
eGroups-EW/0.82 |
awk '{ if (length($0) > max) max=length($0) } END { print max }' file.txt
--- Em address@hidden, Moacir Souza <moacir.souza@...> escreveu
>
> Hum,
>
> Conheço essa forma:
>
> $ awk '{print length, $0}' teste | sort -nr
>
> Perceba:
>
> $ cat teste
> 111111111111111111111
> 222222222222222222222222222222
> 222222222222222222222222222222
> 6666666666666666666666666666666666666666666666
> 33333333333333333333333333333333333333333
> 33333333333333333333333333333333333333333
> 33333333333333333333333333333333333333333
> 444444444
> 5555555555555555555
>
> $ awk '{print length, $0}' teste | sort -nr | head -n 1
> 46 6666666666666666666666666666666666666666666666
>
> É claro que se quiser ver todas as linhas em ordem decrescente de
> tamanho basta remover o "| head -n 1".
>
> Abraços,
> Moacir Filho
>
> --
> ==========================================
> Moacir da Cruz Souza Filho
>
> Analista de Sistemas: Suporte Unix Avançado
> Mestrando em Ciências da Computação
> Bacharel em Engenharia da Computação
> Técnico em Eletrônica
> Linux user #449600
> ==========================================
>