I'd like the output of this command to be on a single line :
$ lscpu -J | jq -r '.lscpu[] | select(.field=="CPU(s):").data " x ", select(.field=="Model name:").data'
4 x
AMD A4-6210 APU with AMD Radeon R3 Graphics
So I tried this but it outputs ... nothing :
$ lscpu -J | jq -r '.lscpu[] | select(.field=="CPU(s):").data " x " select(.field=="Model name:").data'
CodePudding user response:
You can keep the two items in a list, then join them together :
lscpu -J | jq -r '.lscpu |
map(select(.field |
IN("CPU(s):","Model name:")
).data
) |
join(" x ")'