andrew andrew - 1 year ago 112
Linux Question

Concatenate two instructions in bash script

I would like to make program with option -j after checking how many cores cpu has got.

x="grep -c ^processor /proc/cpuinfo"
make -j${x}

x variable display number of cores. make -j${x} not working

Answer Source

You'll want to capture the output of the command into a string through a subshell:

x=$(grep -c ^processor /proc/cpuinfo)
make -j"${x}"
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download