2

What is the default delimiter for sort's -k option? I searched some man page and samples and still feel lost.

4

The GNU sort documentation for the -t option says

By default, fields are separated by the empty string between a non-blank character and a blank character. By default a blank is a space or a tab, but the LC_CTYPE locale can change this.

POSIX says

If -t is not specified, <blank> characters shall be used as default field separators; each maximal non-empty sequence of <blank> characters that follows a non- <blank> shall be a field separator.

Both amount to the same thing: by default, any sequence of whitespace characters separate fields, and the whitespace characters are part of the (following) field.

Thus

  foo  bar

(with two spaces at the beginning) is treated by sort as containing two fields,

  foo

and

  bar

(again with two spaces at the beginning).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.