[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: How to sort ignoring digits? (was: Contacts printing)



On Fri, Nov 09, 2007 at 12:48:31PM +0100, Rodolfo Medina wrote:
> On Thu, Nov 08, 2007 at 03:42:33PM +0100, Rodolfo Medina wrote:
> 
> >> >> > In the documentation of `sort' I couldn't find the possibility of
> >> >> > ignoring digits.  I have a document that contains names and phone
> >> >> > numbers and I wish to sort it by names.  The `-k' option doesn't seem
> >> >> > to help because names and numbers are not in definite fields.
> >>
> >> [...]
> >>
> >> Here are a few lines from the file:
> >> 
> >> 3938269241 320192481 Stan Laurel
> >> 3939424701 0815605311 Oliver Hardy
> >> 800151611 800822051 Harpo Marx
> >> ABC Travel 0111111111 33811111111
> >> Acade;Paolo;;; 335111111 Paolo Acade
> >> Acade;Pasquale;;; 335122211 Pasquale Acade
> >> 
> >> I wish it to be sorted by letters (i.e. by names) - and also eliminate those
> >> ugly semicolons!

...
snip my help for removiing ';' and request for desired format for the
file
...

> All I want is to sort lines by letters ignoring digits.  It's amazing to me that
> such a potent tool as `sort' can't do that!  Maybe some other tool?

Well, if you read the manpage of sort, you will see that it
can't. This is a functino of two things. 1) the data you are supplying
is in an inconsistent format so that it is impossible to select a
field to sort on. 2) the sort program doesn't have an "ignore
numerics" option. 

That leaves you two choices if you are determined to use sort.
1) fix the data or 2) fix the program. 

There are many other ways to solve this problem and probably a simple
perl program is the easiest, fastest way to do it. There are many perl
tutorials on the web that could help you.

good luck

A

Attachment: signature.asc
Description: Digital signature


Reply to: