Skip to content
Advertisement

Sort command is printing in unordered sequence in linux terminal

I have one file named temp following are the data in the file

0.9
1
2
3
10
4
5
6

When i am execute sort temp in the terminal i am getting the answer as

0.9
1
10
2
3
4
5

But my expected answer is

0.9
1
2
3
4
5
10

Can anyone help me in this?

Advertisement

Answer

See man sort:

  -n, --numeric-sort
          compare according to string numerical value

Thus, use

sort -n temp
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement