sed question
hi,
please reply to the list only...
here is my script fragment:
=====
#!/bin/bash
#this doesn't work...
echo -e "\n\nThis doesn't work.\n\n"
old_summary=`echo "Previous glitches and inconsistencies were due to a missing / at the end of the baseurl... ,.#*$+%*$&#+(*={_})"`
echo "Summary -->${old_summary}<--"
result=`echo "summary: \"\"" | sed -e "s/^summary: .*$/summary: \"${old_summary}\"/"`
echo -e "Result -->${result}<--\n\n"
#this does work...
echo -e "\n\nThis does work.\n\n"
old_summary=`echo "Previous glitches and inconsistencies were due to a missing / at the end of the baseurl... ,.#*$+%*$&#+(*={_})" | sed -e 's#/#\\\/#g'`
echo "Summary -->${old_summary}<--"
result=`echo "summary: \"\"" | sed -e "s/^summary: .*$/summary: \"${old_summary}\"/"`
echo -e "Result -->${result}<--\n\n"
=====
here are the results:
=====
This doesn't work.
Summary -->Previous glitches and inconsistencies were due to a missing / at the end of the baseurl... ,.#*$+%*$&#+(*={_})<--
sed: -e expression #1, char 89: unknown option to `s'
Result --><--
This does work.
Summary -->Previous glitches and inconsistencies were due to a missing \/ at the end of the baseurl... ,.#*$+%*$&#+(*={_})<--
Result -->summary: "Previous glitches and inconsistencies were due to a missing / at the end of the baseurl... ,.#*$+%*$summary: ""#+(*={_})"<--
=====
my question is about why i need to pre-process the summary to escape the
slash? i use other characters in the summaries without issues just that
slash causes problems... ?????
i do expect a backslash to present problems to scripts but not a simple
forwards slash... hmm...
songbird
Reply to: