Escaping quote marks
aart at mtack.xs4all.nl
Fri Nov 20 20:36:33 UTC 2009
On Fri, 20 Nov 2009 11:57:54 -0800, Ray Parrish wrote:
> Nils Kassube wrote:
>> Ray Parrish wrote:
>>> Is there any way to get the code to work correctly so it does not
>>> break the urls on space characters?
>> Maybe replace each space character of the URL with "%20"?
> I have already manually edited the site map file, and replaced all of
> the space characters with %20, but I would like to know how to handle
> the spaces in my script so that doesn't have to be done.
> I'm releasing the script as open source software, and it would be nice
> if I did not have to tell my users they need to manually replace all of
> the space characters with %20 in their site maps.
> Ahhh, it just dawned on me... I bet I can replace the space characters
> with %20 as I load each line in from the file. I have no idea how to do
> that, as bash is not real string handling friendly, but I will work on
> it some, and see if I can figure out how to.
> Later, Ray Parrish
In bash I would use sed for that. "sed s/ /%20/g" from the top of my
head. You might have to do some escaping. You can first transform the
whole file and then pass it trough the rest off your script, but it is
also possible to do it line by line, I think. Read up on it, sed is a
rather powerfull tool, together with awk I have used it a lot over the
years. But you can also use perl off course for all off your script. It
is what I do when things get a bit complicated for bash, sed and awk.
More information about the ubuntu-users