[mythtv-users] Script quoting problem

Russell Gower mythtv at thegowers.me.uk
Sat Apr 7 19:25:49 UTC 2018


—cut--

> 
> My script (script.sh) is:
> 
> ----------------
> # Cut everything after the point
> oldname=$(ls *.ts | cut -d. -f1)
> newname=$(ls *.mpg | cut -d. -f1)
> 
> # Rename file
> for file in *.ts; do
I think this is your problem
> 	mv $file $(echo $file | sed 's/$oldname/$newname/g’)

on the first iteration around the loop you are echoing 1234.ts and piping it into sed, the problem is you are asking sed to replace “1234 5678” with “film1 film2” as sed doesn’t find a match it returns "1234.ts” again.

I’m guessing what you are trying to achieve isn’t as straight forward as just renaming two files, if you can describe your aim I’ll try and help you with the script.

Regards
  Russell


More information about the mythtv-users mailing list