I am using the following sed command to
##URL## with C:\\DOCUME~1\\abcde\\APPLIC~1\\URL
as
sed "s^$2^$3^g"
where $2 is ##URL##
and $3 is C:\\DOCUME~1\\abcde\\APPLIC~1\\URL
but i get the output as
C:\DOCUME~1\abcde\APPLIC~1\URL
How can i get the out put as "C:\\DOCUME~1\\abcde\\APPLIC~1\\URL"
Your unnecessarily complex method is hiding what sed is doing. It appears you're not escaping enough.
sed 's/\//\/\/'
Initial '/' would output '//'
i didnt really get this
my script is like this
#!/bin/bash
if [ $# -lt 3 ] ; then
echo -e "Wrong number of parameters."
echo -e "Usage:"
echo -e " FindReplace 'filepat' findstring replacestring\n"
exit 1
fi
echo $1 $2 $3
for i in `find . -name "$1" -exec grep -l "$2" {} \;`
do
#echo "iiiiiiiiiiiiiiiiiiiiiiiiiii"$i
mv "$i" "$i.sedsave"
sed "s^$2^$3^g" "$i.sedsave" > "$i"
echo "Replacing $2 with $3 in $i"
rm "$i.sedsave"
done
how will i put escaping into it so that \\ is not removed