Escaping quote marks

Ray Parrish crp at cmc.net
Sun Nov 22 11:26:18 UTC 2009


Nils Kassube wrote:
> Ray Parrish wrote:
>   
>> Thanks for the commented code this time. I'm still fuzzy on the
>>  meanings of the things like #, and % in your code, but I get the
>>  general idea of what is going on. Could you elaborate a bit? Sorry
>>  8-)
>>     
>
> From [1]:
>
> | ${parameter#word}
> | ${parameter##word}
> | The word is expanded to produce a pattern just as in filename
> | expansion (see Filename Expansion). If the pattern matches the
> | beginning of the expanded value of parameter, then the result of the
> | expansion is the expanded value of parameter with the shortest
> | matching pattern (the ‘#’ case) or the longest matching pattern (the
> | ‘##’ case) deleted. If parameter is ‘@’ or ‘*’, the pattern removal
> | operation is applied to each positional parameter in turn, and the
> | expansion is the resultant list.
>
> And similarly ${parameter%word} deletes at the end of the string.
>
>   
>> About my code and multiple spaces... wouldn't bash just ignore extra
>> spaces between command line arguments? I would think it would still
>> work, but I'm no expert. 8-)
>>     
>
> Yes, bash would ignore the extra spaces and that would change the final
> URL. If the original URL included "some  text" (2 spaces) it should be
> "some%20%20text" after encoding but with your code it would be
> "some%20text". Anyway, it probably doesn't matter because it is unlikely
> that your map URLs include double spaces. Just be careful if you use the
> same code for something different.
>
>
> Nils
>
> [1] <http://www.gnu.org/software/bash/manual/html_node/Shell-Parameter-Expansion.html#Shell-Parameter-Expansion>
>   
Hello again,

I've been reading that doc in the link you posted, and I had a question. 
>From what I am reading the following would replace all spaces in a 
string with %20

ThisLine=${ThisLine/ /%20}

Am I correct in my understanding of this syntax?

Thanks, 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