Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
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.
I'm reading GNU sort recently, and it's implementation is almost like this
It's amazing that the sort program running so fast, cuz gnu sort contains like 20+ structure and alot of macros and so on, almost drive me crazy!!!
okay its not what I'm here, this is why I'm here.
Still I havent figure out that how to make
Code:
$ sort *
work? I didnt finish read everything of sort, so maybe gnu sort is be able to handle this situation, or it's the job of shell?
I'm trying to clone a simple edition or gnu sort for practice of writing a real program
work? I didnt finish read everything of sort, so maybe gnu sort is be able to handle this situation, or it's the job of shell?
I'm trying to clone a simple edition or gnu sort for practice of writing a real program
sort * will take the combined content of all files in the current directory (ecxept those whose name starts with a dot), sort it and write the result to standard output. If some of the files are binaries, the output will look funny, and your terminal may switch to an Amharic font.
Nothing particular is needed to make this work, just type it and enjoy.
Or did you have something else in mind? It's not quite clear to me what you want.
sort * will take the combined content of all files in the current directory (ecxept those whose name starts with a dot), sort it and write the result to standard output. If some of the files are binaries, the output will look funny, and your terminal may switch to an Amharic font.
Nothing particular is needed to make this work, just type it and enjoy.
Or did you have something else in mind? It's not quite clear to me what you want.
Well, I mean I'm cloning GNU sort program and I wanna know how to make "sort *" works for my sort program...
Well, I mean I'm cloning GNU sort program and I wanna know how to make "sort *" works for my sort program...
Your clone needs to take an unlimited number of filename parameters. When you run clone *, the shell will expand the asterisk to the list of files in the current directory, and your clone will have to process all files.
There is a library routine named getopt that will help you with this task.
The shell will pass in the list of all files in the current directory. That has nothing to do with your program; by the time your program has been loaded, initialised and set to run, argv is pointing to the start of the char array of list of files.
I can't help you on the method GNU sort uses to speed up its sort as I don't know anything about it.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.