Linux Commands Helper
💬 Your AI-powered Linux assistant
sort Command - Sort Lines of Text Files
The sort command is used to sort lines of text files. It can sort alphabetically, numerically, or by other criteria, and is commonly used in text processing pipelines.
Syntax
sort [options] [file...]
Examples
sort file.txt
Sort the lines in file.txt alphabetically.
sort -n numbers.txt
Sort the lines in numbers.txt numerically.
sort -r file.txt
Sort the lines in file.txt in reverse order.
Notes
- Use the
-u
option to output only the first of an equal run (unique lines). - Combine with
uniq
to remove duplicate lines after sorting. - Can be used in pipelines with
cat
,cut
, and other text processing tools.