case statement needs fixing
Ray Parrish
crp at cmc.net
Fri Nov 20 08:24:22 UTC 2009
Ray Parrish wrote:
> Hello,
>
> I have the following code
>
> while read ThisLine; do
> case "$ThisLine" in
> "<loc>"*)
> URLs="$URLs $ThisLine";;
> esac
> done < "$MapName"
> echo "URLs $URLs"
>
> $MapName is assigned the name of a google site map file. I've tried
> several variations to match the
> <loc>http://www.somesite.com/index.html</loc> lines in the file so I can
> concatenate them into one long string.
>
> Still echo keeps dumping an empty string back at me, so I'm not sure
> what I am doing wrong with this one.
>
> Does anyone know why this is not working?
>
> Thanks, Ray Parrish
>
Hello again,
I figured it out, here is the corrected code -
while read ThisLine; do
case "$ThisLine" in
*\<loc\>*)
URLs="$URLs $ThisLine";;
esac
done < "$MapName"
echo "URLs $URLs"
I had to escape the <> symbols.
Later, Ray Parrish
--
The Future of Technology.
http://www.rayslinks.com/The%20Future%20of%20Technology.html
Ray's Links, a variety of links to usefull things, and articles by Ray.
http://www.rayslinks.com
Writings of "The" Schizophrenic, what it's like to be a schizo, and other
things, including my poetry.
http://www.writingsoftheschizophrenic.com
More information about the ubuntu-users
mailing list