I'm trying to replace all \
with \\
in bash, I'm doing it like this but bash gets stuck in a never-ending loop. Where am I going wrong?
myVar="${myVar//\//\\\\}"
I'm trying to replace all \
with \\
in bash, I'm doing it like this but bash gets stuck in a never-ending loop. Where am I going wrong?
myVar="${myVar//\//\\\\}"
You can use sed
for that:
echo "hello\world\hello\world" | sed 's/\\/\\\\/g'
Outputs:
hello\\world\\hello\\world