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.
bash-3.1$ time mawk 'NR >= 300 && NR <= 1500' out > tt
real 0m0.003s
user 0m0.001s
sys 0m0.003s
bash-3.1$ time mm 300 1500 out > ttttt
real 0m0.001s
user 0m0.000s
sys 0m0.001s
bash-3.1$ time awk 'NR >= 300 && NR <= 1500' out > tt
real 0m0.004s
user 0m0.002s
sys 0m0.001s
bash-3.1$ time sed -n '300,1500 p' out > tttt
real 0m0.003s
user 0m0.002s
sys 0m0.001s
Well, you're right about sed, it's just as fast as the C program:
Code:
bash-3.1$ time sed -n '300,1500{p;q}' out > ttt
real 0m0.001s
user 0m0.001s
sys 0m0.000s
bash-3.1$ time sed -n '300,1500{p;q}' out > ttt
real 0m0.001s
user 0m0.000s
sys 0m0.001s
But awk and mawk still don't do any better:
Code:
bash-3.1$ time awk 'NR>=300{print}NR==1500{exit}' out > tt
real 0m0.004s
user 0m0.001s
sys 0m0.003s
bash-3.1$ time mawk 'NR>=300{print}NR==1500{exit}' out > tt
real 0m0.003s
user 0m0.000s
sys 0m0.003s
Strange ...
Well, at least you can use sed and don't need the program I posted.
Does that really make any difference to the speed? I thought it just stripped out things like debug symbols. ie. Took up less disk space, but didn't make it faster.
Does that really make any difference to the speed? I thought it just stripped out things like debug symbols. ie. Took up less disk space, but didn't make it faster.
well, maybe just a bit faster, because it takes less time to load it into RAM and it can skip over the unneeded symbols ... I'm not sure, but it does at least save space.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.