I remove the last slash of my variable:
v="/my/path/"
echo $v | sed 's/\/$//' # echoes /my/path
Now I want to remove a pattern at the end of my variable. This pattern should be set in another variable:
pattern="/"
v="/my/path/"
echo $v | sed 's/"$pattern"$//' # echoes /my/path/
It does not work. I tried escaping in case of special character such as "/" :
echo $v | sed 's/\"$pattern"$//' # echoes /my/path/
None expected result either.
How should I proceed?