Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am looking to use more than one core when replacing values with sed in bash, is this possible?

share|improve this question
How complex is the sed script that multiple cores would be any sort of help? – Ignacio Vazquez-Abrams Jun 17 '13 at 16:27
You could just split the file and process each half in a different sed process, but if the script is complicated and involves tweaking the different sed spaces, it wouldn’t work. On simple scripts it should work, however. – qdii Jun 17 '13 at 17:06
up vote 1 down vote accepted

The short answer: probably no.

Longer answer: It really depends. What's your sed like? What's the input/output? Is it multiple scripts and multiple input files? Then you can run multiple instances, and the scheduler will probably distribute this to run on multiple cores. Is it one long input file? then the answer is maybe, but probably not.

Maybe you can split the file into chunks and process those ONLY under certain strict conditions, namely your sed doesn't care about line numbers. Something like "delete line 2" is very different on a single file vs one file chunked to pieces. sed can use state, and if you split the file, you'd have to keep this editing state consistent.

share|improve this answer

You might try running several scripts in parallel. See this question:

As you will see in my own answer, it's not automatic that multiple cores will allow you to get faster results (though of course it can happen).

share|improve this answer

Usually, that cannot be done with SED. If you are wanting better performance, perhaps you could try using AWK or Python3 instead.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .