Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

3 Answers 3

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: http://unix.stackexchange.com/questions/79501/executing-piped-commands-in-parallel

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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.