[Intro Music]
We have just discussed how to
create archives, and how to compress
them. Also, I have shown you how to
extract contents from the
compressed archive. And for that
you could use just a single utility
called 'tar'. It's very powerful utility,
and it has a lot of different other
options. And before going on, let
me quickly enter a command 'file', and
here will be path to archive, and
recap that we have created file
called 'archive.tar.gz', and if I
enter such command, I will see
actually details about this file.
And I will see that this file is 'gzip
compressed data'. That actually
proves that this file was
compressed using 'gzip' utility.
Alright, let me quickly go one
level up and remove this temporary
folder, 'rm -r tmp'; and also let
me remove 'archive.tar.gz', because I
have placed it in the root
directory. All right, now we are
good to go. And in this lecture, I
will explain you how to sort files
and how to sort the contents of the
file. And for that, we will use two
commands 'ls' and 'sort'. First let
me demonstrate to you how you could
sort files here in this output.
And notice that by default files
and folders are sorted by names.
And here you see that names start
from 'e' and the last name has 'z' in
my case. Alright, let me
demonstrate to you how you could
sort this output, for example, by
size of every file or directory.
Let's do following, let's 'ls --help';
and here I'll use 'grep'; and
let's find all options that have
'sort' somewhere like this. And
I'll see that there are some
options that have 'sort' in
description. For example, using
'-S', we can sort by file
size and largest files will be
first. Also using '--sort'
option, please note that this
option is different from '-S',
because those options are
located on different lines. This
option has additional mandatory
argument 'WORD'; and we could use
here such words as 'size', 'none', and for
example, 'time'. And with this option,
'--sort' and argument 'time',
we're able to sort files by
creation or modification time. All
right, let's now try those two
options. And first, let's try '-S'.
Let's clear terminal, and
here type 'l', and 'S';
press Enter; and here I'll see that
file and folders will be sorted by
file size. Of course, we're able to
add here additional '-h' option,
'human'; and now we will see sizes in
kilobytes, megabytes and so on.
Also, we could add additional
option 'r', that will reverse
sorting; and now I'll see smallest
files first. This is how we are able to
quickly sort files by size. Now
let's try to use
'--sort' option. 'ls -l', and here
let's add the option '--sort'; and here
will be equal sign. And if I press
Enter now, I will see actually all
possible arguments that we are able
to use along with this '--sort'
option. And let's sort for example
byte size. '--sort=
size'. Recap that here we supply
argument for this 'sort' option. We
have talked about that before. All
right, press Enter. And now I see
that files were sorted by size. If
I add here additional 'h' option, I
will see actually same result as we
have seen before, and it is
actually alternative for
'-S' option. All right, now
let's try to sort by additional
argument and that will be 'time', time
of creation. 'time', and now we will
see that the files will be sorted
by modification date, and newest
files appear here first. Notice
that this file was modified at the
1st June, and the last file in
this list was modified at the
27th May. Alright, now let's also
sort by extension. Here will be
'extension', like so. And now I will
see that the 'txt' files, for example,
will be placed at the end, 'pdf' files
will be grouped here, 'conf' files
will be grouped here. We have
applied sorting by extension of the
file. Alright, this is how you're
able to sort the result of the 'ls'
command. Now, let's move forward, and
let me explain you know how to sort
the contents of the file, but let's
proceed after the small pause. I'll
see you next. Bye-Bye.
[no audio]