The sort command in Linux is used to sort lines of text files. Here are some basic usages:
-
Sort a file alphabetically:
sort filename.txt -
Sort in reverse order:
sort -r filename.txt -
Sort numerically (useful for numbers):
sort -n filename.txt -
Sort by a specific column (for example, the second column):
sort -k2 filename.txt -
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.
