[kwlug-disc] Parsing Devices Names

John Driezen jdriezen at sympatico.ca
Sat Dec 3 09:32:05 EST 2016


I am doing some modifications to the scripts supplied with vortexbox 
2.4.  I am trying to parse the output of wodim --devices to extract the 
device names.

wodim: Overview of accessible drives (4 found) :
-------------------------------------------------------------------------
  0  dev='/dev/sr0'    rwrw-- : 'HL-DT-ST' 'DVD-RAM GH22NS30'
  1  dev='/dev/sr1'    rwrw-- : 'HL-DT-ST' 'DVDRAM GH22NS50'
  2  dev='/dev/sr2'    rwrw-- : 'HL-DT-ST' 'DVDRAM GH22NS50'
  3  dev='/dev/sr3'    rwrw-- : 'ATAPI' 'DVD A  DH16A6L'
-------------------------------------------------------------------------

The following command

wodim --devices | awk '/dev=/ { print substr($2,index($2,"/"),8) }'

produces the following desired output:

/dev/sr0
/dev/sr1
/dev/sr2
/dev/sr3

except that I don't want to assume that the length of the device name is 
only 8 characters long.  Suggestions anyone?  A sed script would be 
acceptable as well, but I don't know sed.

John Driezen

jdriezen at sympatico.ca






More information about the kwlug-disc mailing list