var="/a/bc/def/file"
echo "${var//\//\\/}"