[clug] Help with bash script

David Deaves David.Deaves at dd.id.au
Mon Nov 3 11:10:44 GMT 2008


Steve Jenkin wrote:
> 
> Hard ('...') and Soft ("...") quoting makes the contained string a
> single word. Variable substitution is done within Soft quotes, not Hard.
> That includes backticks and \xxx.
> 
> It's easy with Soft quotes to create a string containing *all*
> permissible characters - including `, ', ", $.
> 
> With Hard quotes, it's trivial to create *almost* any string - barring '
> - the termination char.
> 
> Anyone got a nice way to do this??? [real question, not rhetorical]
> 


To create a string with a whole swag of special chars in it, including '
do most of the specials inside 's then when you need a ', close the quoting 's
then put the required ' inside "", eg.

ff='+-_="'"'"
echo $ff

Hard to read at first but works.  This trick comes in very handy when trying to
get the correct quoting inside awk code inside a shell script.


Dave !




More information about the linux mailing list