What does the -n option do in the sort command?

The -n option in the sort command is used to sort the input numerically. This means that when you use sort -n, it will compare the numbers in the input and sort them based on their numerical value rather than their lexicographical (alphabetical) order.

For example, if you have a file with the following numbers:

10
2
33
1

Using the command:

sort -n filename.txt

The output will be:

1
2
10
33

This ensures that the numbers are sorted in ascending numerical order.

0 Comments

no data
Be the first to share your comment!