I am trying to get the BusID's of each video card stored in a server and putting them in a variable each to be used for an input to a simple find and replace perl script. How would I go about getting the BusID's of each device listed when I run "lspci | grep VGA" for example.
Thanks
You can use awk to delineate output by spaces. In the fragment below, (assuming a single line was returned by the
lspci | grep VGA
) the$1
refers to the first component up to a space. $2 would be VGA, $3 compatible, etc ... like this:In Bash, you would extract the component via awk and assign it to $var, like so:
echo $var
should return00:0f.0