Linux Ask!

Linux Ask! is a Q & A web site specific for Linux related questions. Questions are collected, answered and audited by experienced Linux users.

Jul 032011
 

Sort numerical value using the sort command

Answer:

Assume you have a text file contains the following content:

1
2
3
10

When you use the sort command to sort them, it will give the following output:

# sort test.txt
1
10
2
3

So you need to sort them according to the numerical values?

Try with the n flag:

# sort -n test.txt
1
2
3
10

 Leave a Reply

(required)

(required)

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>