[SOLVED] Not Sure how to use parallel command with awk
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.
But in both cases you have to specify the list of input files parallel will be run against. If you only have one file gamenums.txt I don't see how you can use parallel.
You should think of parallel as of xargs that runs the specified command against each file in the list, but different from xargs does it, well, in parallel.
Instead of different input files those could be different sets of arguments to the command, too.
But in both cases you have to specify the list of input files parallel will be run against. If you only have one file gamenums.txt I don't see how you can use parallel.
You should think of parallel as of xargs that runs the specified command against each file in the list, but different from xargs does it, well, in parallel.
Instead of different input files those could be different sets of arguments to the command, too.
It is GNU parallel from ubuntu
Quote:
Originally Posted by syg00
Every time I look at GNU parallel I get a headache. The authors think it's a cinch, but I find it arcane to wrestle into shape.
I agree. It's very complicated to understand unless you're a kernel programmer.
For each line of patterns.txt you are splitting the line and starting a new awk and reading all of gamenums.txt, looking for a similar line. Better would be to write a small program (for example in python) that reads the smaller of the two files into memory, sorts it, and then runs through the other one line-by-line to search for the matches with something better than linear time. This converts your problem from O(n^2) to O(n log n).
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.