Convert string output(bash script) -


how convert output vendor_id : genuineintel vendor_id = genuineintel using 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 $(..) since easier nest. remember double quote variable expansions $vendorid -> "$vendorid" or undergo word splitting.

tr in case change colons equal signs, eg:

% echo "a:b:c" | tr ':' '=' a=b=c 

Popular posts from this blog

php - How should I create my API for mobile applications (Needs Authentication) -

5 Reasons to Blog Anonymously (and 5 Reasons Not To)

Google AdWords and AdSense - A Dynamic Small Business Marketing Duo