Following the original issue described here:- Rip chapters of a DVD to separate files
..would someone help us understand what the following code is doing:-
# count Titles, and count Cells per title.
# eg. ${cell[1]} is the Count of Cells for the first title
# ${cell[titles]} is the Count of Cells for the last title
eval $(lsdvd | sed -n 's/Title: \([0-9]\+\), .* Chapters: \([0-9]\+\), Cells: .*/cells[$((10#\1))]=$((10#\2));/p')
titles=${#cells[@]} title_num=2 from_cell=1 to_cell=${cell[title_num]}
We'd like to do the same thing and have tried to use the code. Unfortunately it doesn't work for us and because our understanding is limited we are unable to debug it.
We understand the basic idea of using sed but can't understand how it is managing to:-
- Resolve any pattern to in order to substitute.
- Produce any pattern to substitue with.
Also, its coupling here with eval() is beyond us. Plus there are three uses of # that we just don't get either.
Please help. Thanks.