sort

From Juneday education
Jump to: navigation, search


Description

sort - sort lines of text files.

On this page we only give you a short introduction with a few examples. We encourage you to read the manual (man sort).

Example output

Sort file list

Let's create some files to sort first.

$ touch file-{a..c}{0..3}
$ ls
file-a0  file-a2  file-b0  file-b2  file-c0  file-c2
file-a1  file-a3  file-b1  file-b3  file-c1  file-c3

And now list them in alphabetical order using sort:

$ ls | sort
file-a0
file-a1
file-a2
file-a3
file-b0
file-b1
file-b2
file-b3
file-c0
file-c1
file-c2
file-c3