Let's suppose I have this variable:
DATE="04/Jun/2014:15:54:26"
Therein I need to replace /
with \/
in order to get the string:
"04\/Jun\/2014:15:54:26"
I tried tr
as follows:
echo "04\Jun\2014:15:54:26" | tr '\' '\\/'
But this results in: "04\Jun\2014:15:54:26"
.
It does not satisfy me. Can anyone help?
No need to use an echo + a pipe + sed.
A simple substitution variable is enough and faster:
echo ${DATE//\//\\/}
#> 04\/Jun\/2014:15:54:26