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

html - Firefox flex bug applied to buttons? -

html - Missing border-right in select on Firefox -

python - build a suggestions list using fuzzywuzzy -