[kwlug-disc] Parsing Devices Names
William Park
opengeometry at yahoo.ca
Sat Dec 3 13:38:07 EST 2016
On Sat, Dec 03, 2016 at 09:32:05AM -0500, John Driezen wrote:
> 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) }'
If it is always
dev='...'
then
wodim --devices | awk -F \' '/dev=/ {print $2}'
>
> 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