What is the basic usage of the 'sort' command?

The sort command in Linux is used to sort lines of text files. Here are some basic usages:

  1. Sort a file alphabetically:

    sort filename.txt
  2. Sort in reverse order:

    sort -r filename.txt
  3. Sort numerically (useful for numbers):

    sort -n filename.txt
  4. Sort by a specific column (for example, the second column):

    sort -k2 filename.txt
  5. Sort and save the output to a new file:

    sort filename.txt -o sorted_filename.txt

These commands will help you organize text data efficiently.

0 Comments

no data
Be the first to share your comment!