[Top][All Lists]

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

Re: 'sort' command -- support more than one field-delimiter

From: Dragan Simic
Subject: Re: 'sort' command -- support more than one field-delimiter
Date: Wed, 18 Oct 2023 16:27:51 +0200

On 2023-10-18 13:48, Bernhard Voelker wrote:
Using the initial example:

  SUSE 10.2 12/7/2006

In natural language, the problem could be described as:
  - with ' ' as the delimiter,
  - take the 3rd field,
  - there, with '/' as delimiter,
  - sort by key 3, 1 and 2 numerically.

Therefore, melting the delimiters into a list like ...

$ sort --field-separators=" /" -n -k5 -k3 -k4 file1.txt

... would not tell correctly which keys to sort by, would it?

Perhaps we could use something like this, which would make sort(1) build the set of sort rules as the command-line options are encountered, in the specified order:

  sort -t ' ' -k 3 -n -t '/' -k 3,2,1

However, it might me a bit too complicated and thus impractical.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]