Escaping quote marks
Ray Leventhal
ubuntu at swhi.net
Fri Nov 20 14:24:35 UTC 2009
Ray Parrish wrote:
> Hello,
>
> I have the following code which I would like to improve.
>
> URLs=""
> while read ThisLine; do
> case "$ThisLine" in
> *\<loc\>*) # if line starts with <loc> concatenate it
> into string variable URLs.
> URLs="$URLs $ThisLine";;
> esac
> done < "$MapName"
> # Prompt user with drop down list of urls to select one to remove
> from site map.
> SelectedLine=`Xdialog --stdout --title "Add URL to Site Map -
> Remove URL" --combobox "Select web page to remove from site map" 10 70
> $URLs`
>
> The problem is that if any of the iines starting with <loc> contain
> spaces in their file names, the combobox presents them broken up at the
> spaces on separate lines in it's drop down list.
>
> I have tried to escape quote marks wrapped around each $ThisLine
> concatenated to the URLs string variable as below to make them
> individual parameters, but when I do this the quote marks get written to
> the drop down list, and the entries are still broken at each space.
>
> URLs="$URLs \"$ThisLine\"";;
>
> Is there any way to get the code to work correctly so it does not break
> the urls on space characters?
>
> Thanks for any help you can be.
>
> Later, Ray Parrish
>
Hi Ray,
I'm not sure if this will work, but does escaping the space characters
have the desired effect?
i.e.: URLs="$URLs\ \"$ThisLine\"";;
or
URLs="$URLs\ $ThisLine";;
HTH,
-Ray
--
=====================================================================
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing in e-mail?
=====================================================================
() ascii ribbon campaign - against html e-mail
/\ www.asciiribbon.org - against proprietary attachments
More information about the ubuntu-users
mailing list