Answer the question
In order to leave comments, you need to log in
How to automatically escape characters in a string variable in shell?
Hello! Can you tell me the name of the utility that, having received a string as input, will give the same answer, but with escaped characters?
for example, I get a certain URI, conjure SED over it, respectively, the sed falls with an error.
Answer the question
In order to leave comments, you need to log in
Here's the solution that worked for me:
function sedeasy {
sed -i "s/$(echo $1 | sed -e 's/\([[\/.*]\|\]\)/\\&/g')/$(echo $2 | sed -e 's/[\/&]/\\&/g')/g" $3
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question