Bash only replaces the variable with double quotes.
This should work:
perl -p -i -e "s/<li ><a href=.*?$SOMEVAR.*?li>\n//g" file.html
EDIT Actually, this may seem strange with \n . Another approach is to use bash concatenation. This should work:
perl -p -i -e 's/<li ><a href=.*?'$SOMEVAR'.*?li>\n//g' file.html
EDIT 2: I just carefully considered what you are trying to do, and this is dangerous. You are using a greedy form .* , Which can fit much larger text than you want. Use .*? Instead . I updated the above expressions.
Chriszuma
source share