Organizing Lists with the sort Command


Article from Issue 52/2005

sort helps you organize file lists and program

output. And if you like, you can even use this small

but powerful tool to merge and sort multiple files.

The sort command allows you to

sort a file line by line. The command

can either process a specified

file or read from standard input. You

decide the sort criteria – sort has parameters

that give you granular control.

Simple Sorting Exercises

/etc/passwd is an excellent place to start

experimenting with sort. If you look

inside the file, you will see that the lines

comprise a number of fields, for example:

Buy this article as PDF

Express-Checkout as PDF
Price $2.95
(incl. VAT)

Buy Linux Magazine

Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content

  • Text Manipulation Tools

    Enjoy a crash course on some of the text-processing and -filtering capabilities found in Linux.

  • Ask Klaus!
  • User Monitoring

    Linux tracks all the actions that take place on your system, including when your users were active and what they did.

  • Ncdu

    Ncdu adds some GUI-like features to the classic du command.

  • Show Me!

    There is nothing that admins hate more than unnecessary typing at the console. That's why Charly's clever alternative exa replaces the classic, but ancient, ls.

comments powered by Disqus

Direct Download

Read full article as PDF:

Commandline_sort.pdf (354.09 kB)