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