3

How can I make a unix command (say a one-liner using cut and awk on a HUGE file) use all 16 cores instead of just 1? This isn't a program where I can use -j and specify the number of CPUs to use...

3 Answers 3

3

Have you tried GNU parallel to parallelize jobs? See http://www.gnu.org/software/parallel/

Sign up to request clarification or add additional context in comments.

1 Comment

For your task you should look into the --pipe option demonstrated here: youtube.com/watch?v=1ntxT-47VPA
1

One possible way is to split your input file into a number of pieces and then launch separate shell pipelines for each piece. Multiple processes will take multiple cores.

2 Comments

but all of the CPUs won't be utilized at the same time right? Will there be moments where any certain CPU is not used?
Multiple processes should use separate CPUs but I'm not totally sure.
0

If you use both cut and awk in the same pipeline, they'll probably run on different CPUs, so you will use two of them. There isn't a simple way to set up a short pipeline like that to use more CPUs than the number of steps in the pipeline.

1 Comment

I have a long command, say something like (cut -f 5 HUGEFILE.txt | awk '{print $1+$2}'). The computer I'm working on says its using 100% of 1 cpu, and that the rest are inactive.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.