I have a script that is running and uses
lspci -s 0a.00.1
This returns
0a.00.1 usb controller some text device 4dc9
Try this, say if the string is stored in the variable foo.
foo=`lspci -s 0a.00.1` # the foo value should be "0a.00.1 usb controller some text device 4dc9" echo ${foo:(-4)} # which should output 4dc9