regex - Cywgin Sed match not working when "/" in string -


testline="this test line: asia/pacific australia" expr="asia\/pacific australia" 

this works:

echo "$testline" | sed 's/asia\/pacific australia/test/g' 

this not:

echo "$testline" | sed 's/$expr/test/g' 

i've tried using multiple "escapes", using different quote marks, using -r , -re sed switches. nothing seems work.

please advise if has working solution. please can advise , provide cygwin output here, many thanks!

first change variable as

expr="asia/pacific australia" 

this should work then

echo "$testline" | sed 's_'"$expr"'_test_g' 

note sed delimiters can choose other chars well, here _


Comments

Popular posts from this blog

symfony - InvalidConfigurationException in SecurityExtension.php line 429: No authentication listener registered for firewall "secured_area" -

angular ui router - 10 digest iterations reached in angularjs when using $state.go -

javascript - Can Piwik report referrer in real time? -