GNU Parallel: Parallel execution of Linux commands

Source: Internet
Author: User

A very interesting question to see on stack overflow today is:

You need a script to process a text file, but this text file can be very large, because of the problem of processing the script, you want to be able to process only a few lines of the text file, like Xargs, and can not use split to split the file, and does not allow the generation of temporary files.

If temporary files are allowed, then it is not difficult to use bash script, which can be implemented using the GNU Parallel tool if temporary files cannot be used. The method is implemented as follows:

Cat Giantfile.txt | Parallel-j 8--pipe-l 50000 Import_script
-j 8: Represents the number of concurrent jobs and does not want parallel execution to be set to 1. You can also run a job for each CPU core by default, without the-J option.

--pipe: Reads a piece of data from stdin and assigns each piece of data to each jobs

-l N: reads up to n rows of data at a time


Here's a parallel tutorial: http://www.gnu.org/software/parallel/parallel_tutorial.html

This is a translation version: http://my.oschina.net/enyo/blog/271612


Here are some examples of parallel used with other Linux commands: http://www.vaikan.com/use-multiple-cpu-cores-with-your-linux-commands/

GNU Parallel: Parallel execution of Linux commands

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.