Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Translate / to \/ 1

Status
Not open for further replies.

MikeAJ

Programmer
May 22, 2002
108
US
I need to replace / with \/ so my sed command doesn't fail, but I'm having problems.

Original Code:
Code:
subj_64=`base64.pl -f=subj.test`
sed -e "s/<SUBJ>/${subj_64}/" in.test > out.test

produces the following error:
Code:
sed: command garbled: s/<SUBJ>/UHJvYmxlbXMgd2l0aCBOSURBUSA4LjEgZG93bmxvYWQ/Cg==/

It's erroring when the base64 output has a / in it. So I changed it to this:
Code:
subj_64=`base64.pl -f=subj.test | tr / \\\/`
sed -e "s/<SUBJ>/${subj_64}/" in.test > out.test

but I can't get it to work. So how can I replace / with \/ using tr?

Thanks,
Mike
 
Have you tried this instead ?
subj_64=`base64.pl -f=subj.test`
sed -e "s!<SUBJ>!${subj_64}!" in.test > out.test

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Awesome! That worked like a charm! I didn't know you can use "!".

Thanks so much!
Mike
 
You can use almost any character after the 's' command, but "/", "!" and "#" are used most frequently by convention.

Annihilannic.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top