Article 57NT5 Bash script to generate command

Bash script to generate command

by
GPGAgent
from LinuxQuestions.org on (#57NT5)
Ok folks, bash is causing me a minor headache again, and why I just cannot get what is probably really simple into my head, here goes, what I want to generate isCode:HandBrakeCLI -i V/*.iso -t 2 -o Test2.mp4 where 2, one of the title numbers will come from this commandCode:$ lsdvd V/*.iso
Disc Title: DVDVOLUME
Title: 01, Length: 00:00:27.480 Chapters: 04, Cells: 04, Audio streams: 01, Subpictures: 00
Title: 02, Length: 00:48:45.600 Chapters: 10, Cells: 10, Audio streams: 01, Subpictures: 00
Title: 03, Length: 00:48:43.200 Chapters: 10, Cells: 12, Audio streams: 01, Subpictures: 00
Title: 04, Length: 00:48:39.200 Chapters: 10, Cells: 13, Audio streams: 01, Subpictures: 00
Title: 05, Length: 00:49:31.200 Chapters: 10, Cells: 11, Audio streams: 01, Subpictures: 00
Title: 06, Length: 00:05:51.000 Chapters: 04, Cells: 04, Audio streams: 01, Subpictures: 00
Longest track: 05From that I've produced thisCode:$ lsdvd V/*.iso | grep Sub| awk '{print "HandbrakeCLI -i V/*.iso -t " $2 " -o our"$2".mp4"}'
HandbrakeCLI -i V/*.iso -t 01, -o our01,.mp4
HandbrakeCLI -i V/*.iso -t 02, -o our02,.mp4
HandbrakeCLI -i V/*.iso -t 03, -o our03,.mp4
HandbrakeCLI -i V/*.iso -t 04, -o our04,.mp4
HandbrakeCLI -i V/*.iso -t 05, -o our05,.mp4
HandbrakeCLI -i V/*.iso -t 06, -o our06,.mp4and the bit I can't do is to mask out the comma after each track number

I know how to do it on a variableCode:$ X=02,
$ echo ${X//,}
$ 02how do I incorporate that with awk, or is there a much better way.latest?d=yIl2AUoC8zA latest?i=NkLYM6S4c-4:MWfVYjPzOEg:F7zBnMy latest?i=NkLYM6S4c-4:MWfVYjPzOEg:V_sGLiP latest?d=qj6IDK7rITs latest?i=NkLYM6S4c-4:MWfVYjPzOEg:gIN9vFwNkLYM6S4c-4
External Content
Source RSS or Atom Feed
Feed Location https://feeds.feedburner.com/linuxquestions/latest
Feed Title LinuxQuestions.org
Feed Link https://www.linuxquestions.org/questions/
Reply 0 comments