I want to remove a pattern from a string (using sed and pipes), but this pattern is not always the same and is defined previously on a variable.
this example mimics the desired behavior
toremove="Osiris"
mystring="Horus,Osiris,Apis"
mystring=$(echo $mystring | sed -e 's/$toremove//g')
no succcess so far. Output is the same as input,
ยด
instead of'
as single quotes. You also don't say what actually happens and what "no success" actually means. Also note that variables are not expanded within single quotes. Is there any reason you are not doing this withbash
asmystring=${mystring//$toremove/}
? โ Kusalananda Jun 13 '19 at 10:14