What does the -t flag do in the sort command?

0207

The -t flag in the sort command specifies a delimiter that separates fields in the input data. By default, sort uses whitespace as the delimiter, but with the -t option, you can define a custom delimiter.

For example, if you have a colon-separated file and you want to sort based on the second field, you would use:

sort -t: -k2 filename.txt

In this command:

  • -t: sets the delimiter to a colon (:).
  • -k2 indicates that sorting should be based on the second field.

This is useful for sorting structured data where fields are separated by specific characters.

0 Comments

no data
Be the first to share your comment!