Mandriva This Forum is for the discussion of Mandriva (Mandrake) Linux.
Notices
Welcome to
LinuxQuestions.org , a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free.
Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please
contact us . If you need to reset your password,
click here .
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
03-13-2008, 10:04 AM
#1
LQ Newbie
Registered: Mar 2008
Posts: 2
Rep:
sort doesn't work
Hi,
I need to sort a numeric file but my sort command seems doesn't work!
When I use the command:
>sort -n infile
or
>sort -g infile
I obtain the same result that
>sort infile
That means that I get an alphabetically ordered file even if the file is a list of numbers.
I can't figure out what's the problem....could someone halp me, please?
My sort varsion is:
sort (coreutils) 5.2.1
Written by Mike Haertel and Paul Eggert.
Thank you !
03-13-2008, 02:22 PM
#2
Senior Member
Registered: Mar 2002
Location: Los Angeles, CA
Distribution: Debian, Ubuntu
Posts: 1,334
Rep:
Quote:
Originally Posted by
ratti74
Hi,
I need to sort a numeric file but my sort command seems doesn't work!
hmm... maybe we need to see a snippet of the file. Are all the number on one line? Seems to work for me... here's the file I used:
Code:
45 23 2 5 4253
23
423 253
4253
4253
2
55 5 43
12
423 foo
5
5
6 hello
3
453
45
7
4 gah
4
57
3
453
... and the output:
Code:
sort -n some_file
2
3
3
4
4 gah
5
5
6 hello
7
12
23
45
45 23 2 5 4253
55 5 43
57
423 253
423 foo
453
453
4253
4253
are you getting something else?
03-14-2008, 04:31 AM
#3
LQ Newbie
Registered: Mar 2008
Posts: 2
Original Poster
Rep:
This is an example of in_file
2.26102e-10
5.28728e-05
1.43164e-05
1.43164e-05
1.99507e-11
2.79948e-12
4.90768e-10
2.34509e-13
1.32265e-12
8.57706e-16
9.83975e-12
1.81137e-05
9.16633e-16
2.81432e-05
2.81432e-05
0.000318926
6.34414e-06
0.000487889
4.01249e-16
2.82483e-06
4.09477e-09
4.09477e-09
1.09976e-05
5.26564e-03
1.08076e-09
2.54978e-10
1.94235e-08
0.000315027
0.000315027
5.14266e-07
6.51105e-02
8.51396e-07
3.42159e-09
1.42678e-08
When I use the command:
>sort -g in_file
I get...
0.000315027
0.000315027
0.000318926
0.000487889
1.08076e-09
1.09976e-05
1.32265e-12
1.42678e-08
1.43164e-05
1.43164e-05
1.81137e-05
1.94235e-08
1.99507e-11
2.26102e-10
2.34509e-13
2.54978e-10
2.79948e-12
2.81432e-05
2.81432e-05
2.82483e-06
3.42159e-09
4.01249e-16
4.09477e-09
4.09477e-09
4.90768e-10
5.14266e-07
5.26564e-03
5.28728e-05
6.34414e-06
6.51105e-02
8.51396e-07
8.57706e-16
9.16633e-16
9.83975e-12
When I use the command:
>sort -n in_file
I get...the same
0.000315027
0.000315027
0.000318926
0.000487889
1.08076e-09
1.09976e-05
1.32265e-12
1.42678e-08
1.43164e-05
1.43164e-05
1.81137e-05
1.94235e-08
1.99507e-11
2.26102e-10
2.34509e-13
2.54978e-10
2.79948e-12
2.81432e-05
2.81432e-05
2.82483e-06
3.42159e-09
4.01249e-16
4.09477e-09
4.09477e-09
4.90768e-10
5.14266e-07
5.26564e-03
5.28728e-05
6.34414e-06
6.51105e-02
8.51396e-07
8.57706e-16
9.16633e-16
9.83975e-12
the same if I use : sort in_file
It seems to me that options -g or -n doesn't work...
03-14-2008, 04:47 AM
#4
Senior Member
Registered: Oct 2005
Location: Philippines
Distribution: Gentoo, Slackware, LFS
Posts: 1,526
Rep:
what's the problem? it seems to be sorted properly.
03-14-2008, 01:31 PM
#5
Senior Member
Registered: Mar 2002
Location: Los Angeles, CA
Distribution: Debian, Ubuntu
Posts: 1,334
Rep:
Quote:
Originally Posted by
ratti74
This is an example of in_file
When I use the command:
>sort -g in_file
I get...
0.000315027
0.000315027
0.000318926
0.000487889
1.08076e-09
1.09976e-05
1.32265e-12
1.42678e-08
1.43164e-05
1.43164e-05
1.81137e-05
1.94235e-08
1.99507e-11
2.26102e-10
2.34509e-13
2.54978e-10
2.79948e-12
2.81432e-05
2.81432e-05
2.82483e-06
3.42159e-09
4.01249e-16
4.09477e-09
4.09477e-09
4.90768e-10
5.14266e-07
5.26564e-03
5.28728e-05
6.34414e-06
6.51105e-02
8.51396e-07
8.57706e-16
9.16633e-16
9.83975e-12
that's very odd. -g is supposed to recognize scientific notation, and it does on my machine:
Code:
sort -g /tmp/some_file2
4.01249e-16
8.57706e-16
9.16633e-16
2.34509e-13
1.32265e-12
2.79948e-12
9.83975e-12
1.99507e-11
2.26102e-10
2.54978e-10
4.90768e-10
1.08076e-09
3.42159e-09
4.09477e-09
4.09477e-09
1.42678e-08
1.94235e-08
5.14266e-07
8.51396e-07
2.82483e-06
6.34414e-06
1.09976e-05
1.43164e-05
1.43164e-05
1.81137e-05
2.81432e-05
2.81432e-05
5.28728e-05
0.000315027
0.000315027
0.000318926
0.000487889
5.26564e-03
6.51105e-02
don't know why yours isn't working? I'm using sort (GNU coreutils) 5.97
on Debian 4.0 (etch)
03-14-2008, 11:46 PM
#6
Senior Member
Registered: Oct 2005
Location: Philippines
Distribution: Gentoo, Slackware, LFS
Posts: 1,526
Rep:
oic it's the scientific notation
. my mistake. perhaps as also BrianK is asking about versions, your sort command has no support of scientific notations in that version. Or perhaps it was compiled with disabled support for scientific notations. Try to recompile looking for options that enable support for such or try using newer versions of coreutils.
03-15-2008, 12:57 AM
#7
Guru
Registered: Mar 2006
Location: Sydney, Australia
Distribution: Fedora, CentOS, OpenSuse, Slack, Gentoo, Debian, Arch, PCBSD
Posts: 6,678
Rep:
CentOS is version 5.97 too btw
Edit - and it sorts scientific notation fine
Last edited by billymayday; 03-15-2008 at 01:08 AM .
03-15-2008, 01:03 AM
#8
Senior Member
Registered: Oct 2005
Location: Philippines
Distribution: Gentoo, Slackware, LFS
Posts: 1,526
Rep:
ok.. and mistakes in library support too? perhaps?
Thread Tools
Search this Thread
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
All times are GMT -5. The time now is 11:02 AM .
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know .
Latest Threads
LQ News