I'm trying to replacing some URLs in html files with the following line:
quote="\""
$(cd "$tutorials_dir_ios" && `sed -i '' 's#.png?version=.*$quote#.png#$quote#g' *.html`)
So this is supposed to match an URL like
someimage.png?version=123&some=thing"
and replace the part after .png until " occurs (I need to keep the " as tag closing in the html):
someimage.png"
But I'm getting:
sed: 1: "s#.png?version=.*$quote ...": bad flag in substitute command: '$'
I've tried some variations, also by using \x22 as double quote. This also throws:
sed: 1: "s#.png?version=.*\x22#. ...": bad flag in substitute command: '\'
I should mention that I'm running OS X, where sed has slightly different behavior.
What's the correct way to use a single quote using sed within a bash script? In a shell the same command using just a " works of course.
Update
Fixed using double quotes meanwhile. But this is also not working:
$(cd "$tutorials_dir_ios" && `sed -i '' "s#.png?version=.*\"#.png#\"#g" *.html`)
gives
sed: 1: "s#.png?version=.*"#.png ...": bad flag in substitute command: '"'