I want to extract the info from lshw
output where it says:
-cpu
product: ......
I want only the product info of this -cpu
.
How can I do that with awk
or sed
?
You can filter using the utility lshw
, itself:
lshw -C cpu
That prints only the cpu part. But if you only want the product part then you need awk:
lshw -C cpu | awk '$1=="product:"{$1=""; print}'
It searches for the string product:
in the first field variable and removes that part before printing the rest of the line.
Mr Moderator please move this as a comment to chaos’ answer, I can’t comment because I don’t have the beans ;-) I do believe such commands like lshw or lsblk should have a way to return the exact desired string without parsing the output with awk or sed or whatever, especially now that these tools are often localized and you must parse differently according to language! I have been struggling like mad with this issue.