Reputation: 5
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
Upvotes: 0
Views: 43
Reputation: 47099
You can use tr
anslate:
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
Upvotes: 1
Reputation: 19982
Translate the character :
into =
with
tr ':' '=' < /proc/cpuinfo
Assign to a variable with
vendorid=$(tr ':' '=' < /proc/cpuinfo)
Upvotes: 0