hylaeus
hylaeus

Reputation: 255

sorting numbers with the sort command

I would like to sort the values in the following file numbers.txt, below is an example

1.1
1.2
10.0
2.2
1000.0

However when I execute the following cmd

sort numbers.txt

I get the following:

1.1
1.2
10.0
1000.0
2.2

What cmd to I need to sort the numeric values appropriately?

Upvotes: 0

Views: 160

Answers (1)

chepner
chepner

Reputation: 531055

Use the -n flag to sort numerically, instead of lexicographically:

sort -n numbers.txt

Upvotes: 1

Related Questions