This tries to print all the found CD/DVD device names, one per line.
More drive info is added to each line ( code not shown ).
But awk won`t use $c even though the awk manual shows variable usage.
Code: Select all
Info=`cat /proc/sys/dev/cdrom/info`
N=`echo "$Info" |grep 'name:' |awk '{print $3}' |grep -Eo '.$'`
[ "$N" = '' ]&& exit
i=0 ; c=$(($N+3))
while [ $i -le $N ]
do
Drv=`echo "$Info" |grep 'name:' |awk {print $c}`' '
echo $Drv
i=$(($i+1))
done
\x09 and \x0a just don`t work to identify them in most cases.
### NOTE: My PC won`t do: echo $(</proc/sys/dev/cdrom/info)
It only echos or writes to a file part of the read file. But "cat" does work!