Sort a file by numeric order

Say you have the following file, test.txt,

4 blah blah
45 something else
35 blah
1 and more

If you ran sort test.txt, you would get,

1 blah blah
45 something else
35 blah
4 and more

If you want the number column to be sorted, run sort -g test.txt, which outputs,

1 blah blah
4 and more
35 blah
45 something else

References

  • man sort

Page Comments (Click to edit)






[Click to add or edit comments])

Please prepend comments below including a date

Design by N.Design Studio, adapted by solidGone.org (version 1.0.0)
Have a nice day.