I am trying to write a reporting script for my apache logs. Some of the referer URLs in my logs have backslashes in them, and my code can't figure out what to do with them, so it just errors out. I want to replace all '\' characters with '\\', and I can't get it to work. If I run this from the command line:
echo "http://music.domain.com/music.cgi?sc=mus&w=\xb4\xf3\xcd\xe6\xd0\xa6+%B9%F9%BE%B2&clz=" | sed -e 's#\\#\\\\#g'
I get this output:
But if I run it from within my script:
for i in `cat apache.log | sed -e 's#\\#\\\\#g' `; do
I get this error: "sed: -e expression #1, char 8: unterminated `s' command", and my strings are not changed. I have no idea why this isn't working...