How do you pass a variable containing slashes as a pattern to sed
?
For example, if I have the following variable:
var="/Users/Documents/name/file"
I want to pass it to sed
as so:
sed "s/$var/replace/g" "$file"
However I get errors. How can I circumvent the issue?
Question&Answers:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…