sort words by size

sort words by size

am 07.09.2007 16:07:01 von joe

Hello everyone, i am trying to create an ignore list for my
bogofilter. I would like to ignore all words that are less than 4
characters. How can i sort my words list file by length of the words.
Thanks.

Re: sort words by size

am 07.09.2007 16:54:35 von William James

On Sep 7, 9:07 am, joe wrote:
> Hello everyone, i am trying to create an ignore list for my
> bogofilter. I would like to ignore all words that are less than 4
> characters. How can i sort my words list file by length of the words.
> Thanks.

ruby -e 'puts ARGF.sort_by{|w| w.size}' myfile

Re: sort words by size

am 07.09.2007 19:44:11 von Kenan Kalajdzic

joe wrote:
> Hello everyone, i am trying to create an ignore list for my
> bogofilter. I would like to ignore all words that are less than 4
> characters. How can i sort my words list file by length of the words.
> Thanks.

If you only want to ignore the lines that contain less than four
characters, simply use grep:

grep '....' words

If, however, you need to sort the words by length, here is one solution:

awk '{ print $0,length }' words | sort -k2n | awk '{ print $1 }'

--
Kenan Kalajdzic

Re: sort words by size

am 10.09.2007 20:08:03 von joe

Thanks Guys, I ended up using cat file|perl -e 'print sort
{ length($b) <=> length($a) } <>' but opted not to use any ignore
files.