andrew andrew - 6 months ago 41
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


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}"