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

Páxina inicial
Borrar esta mensaxe
Responder a esta mensaxe
Autor: Lorens Kockum
Data:  
Para: Marc Perkel
CC: exim-users
Asunto: Re: [exim] Need a little bash scripting help [OT]
On Sun, Dec 12, 2010 at 04:15:35PM -0800, Marc Perkel wrote:
>
> The problem is that I have a space in the data I'm sorting. The code
> that sets the $count variable includes up to the last space in the string.


I hate jumping on an off-topic bandwagon, but any of the
following should do if eligible duplicates are on adjacent
lines:

| uniq -c | sed -rn 's/^ *([3-9]|[0-9]{2,}) //p'

| uniq -c | grep -v '^ *s/^ *[12] ' | sed 's/^ *[0-9]\+ //'


The first may need a GNU sed, but the second should work anywhere.

Both should neatly avoid any problem with interpreting the rest
of the line (double spaces especially), at the expense of having
to write a regex to define your threshold. If that's a problem,
and you have things like double spaces you want to keep, I'd
look to perl. Heiko's example is nice because it lets you avoid
the sort | uniq -- unless you don't want them. You need to
ask yourself if the list is sorted to begin with (with all
duplicates following each other) or not, and if you want to keep
that order. In other words, taking your example, "three" sorts
after "four", so do you care what happens if the input is

one
two
three
four
two
three
four
three
four
four

? Ah, software specification... http://www.businessballs.com/treeswing.htm

I'll take us back on topic by noting that although I haven't
seen anything on the announce list (how come?) and only a
passing mention here, you should be certain that you're running
exim 4.70 or better 4.72, because 4.70 plugged a remote root
vulnerability that is now public. Debian of course says it's
4.69 plus a debian patch, but well.