Quantcast
Channel: UNIX and Linux Forums
Viewing all articles
Browse latest Browse all 16232

Merge output of 2 commands into variable

$
0
0
I am extracting two pieces of information from the following file: /proc/cpuinfo, that I need to merge into one report.

The first command:
grep -i processor /proc/cpuinfo | awk '{print $1$2,$3}'
yields:
processor: 0
processor: 1
processor: 2
processor: 3


The second command:
grep -i "model name" /proc/cpuinfo | awk '{print $4, $5, $6, $7, " ", $8, $9, $10, $11}'
yields:

Intel(R) Core(TM) i3 CPU M 370 @ 2.40GHz
Intel(R) Core(TM) i3 CPU M 370 @ 2.40GHz
Intel(R) Core(TM) i3 CPU M 370 @ 2.40GHz
Intel(R) Core(TM) i3 CPU M 370 @ 2.40GHz


I want a report that looks like this:
processor: 0 Intel(R) Core(TM) i3 CPU M 370 @ 2.40GHz
processor: 1
Intel(R) Core(TM) i3 CPU M 370 @ 2.40GHz
processor: 2
Intel(R) Core(TM) i3 CPU M 370 @ 2.40GHz
processor: 3
Intel(R) Core(TM) i3 CPU M 370 @ 2.40GHz

I am working from a live CD, so I cannot use files. I figure this can be done using a variable or array. I'm still learning Bash, so a point in the right direction would be most helpful.



Viewing all articles
Browse latest Browse all 16232

Trending Articles