Groups | Search | Server Info | Keyboard shortcuts | Login | Register


Groups > gnu.emacs.help > #60693

Re: Sort from second field instead on second field

From Ralf Fassel <ralfixx@gmx.de>
Newsgroups gnu.emacs.help
Subject Re: Sort from second field instead on second field
Date 2023-03-29 19:28 +0200
Message-ID <yga4jq3v55a.fsf@akutech.de> (permalink)
References <87sfdnlfkj.fsf@munus.decebal.nl>

Show all headers | View raw


* Cecil Westerhof <Cecil@decebal.nl>
| You can sort lines in the region on the second field with:
|     C-u 2 M-x sort-field
>
| In most cases this will probably be enough. But what if I would want
| to sort from the second field to the end of the line?

Mark the region and call

  C-u M-x shell-command-on-region RET sort -k FIELDNUM RET

       -k, --key=KEYDEF
              sort via a key; KEYDEF gives location and type

       KEYDEF  is F[.C][OPTS][,F[.C][OPTS]] for start and stop position, where
       F is a field number and C a character position in the field;  both  are
       origin 1, and the stop position defaults to the line's end. [...]

?  Of course requires an external command compatible with Unix' 'sort(1)'.

R'

Back to gnu.emacs.help | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

Sort from second field instead on second field Cecil Westerhof <Cecil@decebal.nl> - 2023-03-29 17:53 +0200
  Re: Sort from second field instead on second field HASM <hasm@example.invalid> - 2023-03-29 09:39 -0700
    Re: Sort from second field instead on second field Cecil Westerhof <Cecil@decebal.nl> - 2023-03-29 19:55 +0200
  Re: Sort from second field instead on second field Ralf Fassel <ralfixx@gmx.de> - 2023-03-29 19:28 +0200
    Re: Sort from second field instead on second field Cecil Westerhof <Cecil@decebal.nl> - 2023-03-30 07:03 +0200

csiph-web