Learn to sort files at the Linux command line.
Linux sort command summary with examples (3:39)
Videos can also be accessed from the YouTube Playlist.
Our thirty-first word, or command to memorize is
sort from our category
sort allows you to sort lines within
Recall from previous videos, we learned how to inspect files, now we'll see how we can use the computer to quickly process information from these files.
Before we start, it helps to think of commands as mini programs and
most follow this structure:
command -option(s) argument(s).
sort command has
31 options, and arguments include the one or
several files you'd like to sort.
Like most commands, help is available with double-dash
-r option reverses sort order and
-o outputs the sort to a file.
So why is
sort an important command?
Well, we're often faced with data sets we'd like to see in numeric,
alphabetic or date order.
And now you know how to do that.
Okay, the best way to embed this in your memory is by typing in your own terminal window.
Find this on your Mac using a program called Terminal. On Linux use Terminal or Konsole, and currently Microsoft is adding this functionality to Windows.
Here we go, let's start using the
cat command from video 10. For the
most part we've been using
print files straight to the screen. So let's use it for its other
purpose, to concatenate, or combine files,
video05.txt and the same file
video05.txt and call it
video31.txt and then let's just
cat it to the screen.
So we duplicated the file right?
Now, let's use
Okay, good. Oh look, a misspelling (thrid).
Next, we'll sort it in reverse order with
sort -r video31.txt.
There we go. And last, let's
the regular way, but write it to a file called
ls to verify.
Okay now we know how to use
And we know the syntax for commands, options and arguments.
One last tip about the
So why did we create a file for video 32? You'll have to tune in to see
a command that is often used in conjunction with
sort. Ooh, it's a cliffhanger.
Okay, thanks for visiting today. I hope this was a helpful
introduction to the
For an overview of the 100 videos, the 8 quizzes, a cheat sheet, the categories and a Q&A section, visit:
If you support what we're doing, why not subscribe to our YouTube Channel?
findcommand, hit Back.
uniqcommand, click Next.