The-Unix-Shell-Teaching-Notes

4.1 What Does sort -n Do?

The file shell-lesson-data/numbers.txt contains the following lines:

10
2
19
22
6

If we run sort on this file, the output is:

10
19
2
22
6

If we run sort -n on the same file, we get this instead:

2
6
10
19
22

Explain why -n has this effect.

Solution The -n option specifies a numerical rather than an alphanumerical sort.

Episode 4 Exercise 2