ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
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.
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.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
The general_numcompare() function in sort from coreutils-8.9 converts the numbers to the native long double type using the standard strtold() library function. This is used when the -g option is used.
Option -n uses strnumcmp() defined in coreutils-8.9/lib/strnumcmp-in.h, which does not do any numerical conversions. It is purely string-based, and should be able to compare any decimal number strings that fit into memory.
I sincirely hope this was not homework,
Nominal Animal
Last edited by Nominal Animal; 03-21-2011 at 06:03 AM.
I'd guess they would be limited by something like MAX_LINE -probably at least 1024 chars long -or by how much RAM you have for storing it all. You could do without the 'cat' command for faster results:
@gnashley: Some sort implementations may have line length limits, but not GNU sort from the coreutils package. From info sort:
Quote:
GNU `sort' (as specified for all GNU utilities) has no limit on input line length or restrictions on bytes allowed within lines. In addition, if the final byte of an input file is not a newline, GNU `sort' silently supplies one. A line's trailing newline is not part of the line for comparison purposes.
So yes, the limit seems to be the available memory (RAM + swap, or resource limits, whichever are smaller).
Nominal Animal
Last edited by Nominal Animal; 03-21-2011 at 06:03 AM.
My bad! I did not think of checking the source code.
This is not my homework, it is rather my job (second job). Now I feel good.
The other day, I hit the size limit of long long int in C. Of course, it did not happen in test run, and it took several days to debug. I won't run into similar problem.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.