Re: [exim] Need a little bash scripting help [OT]

Páxina inicial
Borrar esta mensaxe
Responder a esta mensaxe
Autor: Heiko Schlittermann
Data:  
Para: exim-users
Asunto: Re: [exim] Need a little bash scripting help [OT]
Marc Perkel <marc@???> (So 12 Dez 2010 23:54:19 CET):
>
>
> On 12/12/2010 2:40 PM, Heiko Schlittermann wrote:
> > Marc Perkel<marc@???> (So 12 Dez 2010 23:26:54 CET):
> >>> in bash:
> >>>
> >>> $ cat test.txt | sort | uniq -c | while read line; do count=${line% *}; if


BTW, useless use of cat :-)

> >>> [ $count -ge 3 ]; then echo ${line/*$count /}; fi; done
> >>> four
> >>> three
> >>> $
> >>>
> >>> Cheers,
> >> Thanks but I'm getting "too many arguments" on
> >>
> >> [ $count -ge 3 ];
> > If you quote $count
> >
> >      [ "$count" -ge 3 ]

> >
> > the error will disappear. But this would fix just the symptom, as any
> > line should have a count prepended.
> >
>
> Well - getting "integer expression expected" now. :(


For testing:

    <test.txt sort | uniq -c | while read line; do count=${line% *}; echo "$count : $line"; done


But the solution using grep is much more clean.

Or try this (it's what I was thinking about when I told you about the -c
option on uniq)

    <test.txt sort | uniq -c | while read count line; do 
        [ $count -ge 2 ] && echo "$line"
    done


--
Heiko :: dresden : linux : SCHLITTERMAN.de
GPG Key 48D0359B : 3061 CFBF 2D88 F034 E8D2 7E92 EE4E AC98 48D0 359B