Copied to clipboard

sort

`sort` command line is used to sort files and print the results line by line. It can also be used to remove duplicate lines from a file.

Example

The sort command line is used to sort files and print the results line by line. It can also be used to remove duplicate lines from a file.

Here are examples of common uses of this command:

  • Sort the contents of the file file.txt and print the result to the terminal:
sort file.txt
  • Sort the contents of the file file.txt and write the result to the file output.txt:
sort file.txt -o output.txt
  • Ignore case, sort the contents of the file file.txt and print the result to the terminal:
sort -f file.txt
  • Sort numerically, sort the contents of the file file.txt and print the result to the terminal:
sort -n file.txt
  • Remove duplicate lines from the file file.txt and print the result to the terminal:
sort -u file.txt
  • Specify the field separator as comma, sort the contents of the file file.txt and print the result to the terminal:
sort -t ',' file.txt