Skip to main content
replaced http://unix.stackexchange.com/ with https://unix.stackexchange.com/
Source Link

Following the original issue described here:- Rip chapters of a DVD to separate filesRip 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:-

  1. Resolve any pattern to in order to substitute.
  2. 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.

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:-

  1. Resolve any pattern to in order to substitute.
  2. 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.

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:-

  1. Resolve any pattern to in order to substitute.
  2. 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.

formatting
Source Link
glenn jackman
  • 88.5k
  • 16
  • 124
  • 179

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:-

  1. Resolve any pattern to in order to substitute.
  2. 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.

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:-

  1. Resolve any pattern to in order to substitute.
  2. 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.

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:-

  1. Resolve any pattern to in order to substitute.
  2. 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.

Source Link
xndr
  • 1
  • 1

Using eval and sed to perform counting and script control

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:-

  1. Resolve any pattern to in order to substitute.
  2. 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.