How do I convert my output vendor_id : GenuineIntel to vendor_id = GenuineIntel using the cut command?
#!/bin/bash
VENDORID=`cat /proc/cpuinfo | grep 'vendor_id'|cut -d`=`-f 5`
vendor_id: GenuineIntel
echo $VENDORID
How do I convert my output vendor_id : GenuineIntel to vendor_id = GenuineIntel using the cut command?
#!/bin/bash
VENDORID=`cat /proc/cpuinfo | grep 'vendor_id'|cut -d`=`-f 5`
vendor_id: GenuineIntel
echo $VENDORID
You can use translate:
vendorid=$(grep 'vender_id' /proc/cpuinfo | tr ':' '=')
printf "%s\n" "$vendorid"
I changed backticks to $(..) since they are easier to nest. Also remember to double quote your variable expansions $vendorid -> "$vendorid" or it will undergo word splitting.
tr will in this case change all colons to equal signs, eg:
% echo "a:b:c" | tr ':' '='
a=b=c
VENDORID=$(sed -n '/vendor_id/{s/:/=/p;q}' /proc/cpuinfo)
{s/:/=/p;q} does - might not be obvious?