Re: Replacing with quotes the ${x/y/z} way.

From: Chris F.A. Johnson (c.fa.johnson_at_rogers.com)
Date: 12/30/03


Date: 30 Dec 2003 18:45:07 GMT

On Tue, 30 Dec 2003 at 02:31 GMT, Mark June wrote:
> Hello,
>
> I have a problem. I do:
>
> $ PS2="> "
>
> $ a=1
>
> $ echo "'"
> '
>
> According to that above, "${a/1/'}" should replace 1 with one single
> quote but:
>
> $ echo "${a/1/'}"
> > bash: unexpected EOF while looking for matching `''
> bash: syntax error: unexpected end of file
>
> And if I try protecting the single quote during the job it does:
>
> $ echo "${a/1/\'}"
> \'
>
> How could I get that 1 replaced with one single quote using that
> method?

q="'"
echo "${a/1/$q}"

-- 
    Chris F.A. Johnson                        http://cfaj.freeshell.org
    ===================================================================
    My code (if any) in this post is copyright 2003, Chris F.A. Johnson
    and may be copied under the terms of the GNU General Public License


Relevant Pages

  • Re: Replacing with quotes the ${x/y/z} way.
    ... On 30 Dec 2003 02:31:37 GMT, Mark June ... > quote but: ... echo "$" ... -- Otto Von Bismarck ...
    (comp.unix.shell)
  • Re: Calc. energy harmonics
    ... :> I will if you remember to mark text you quote. ... Make a total fool out of yourself if you ... Harry C.- Hide quoted text - ...
    (sci.physics)
  • Re: Calc. energy harmonics
    ... :> I will if you remember to mark text you quote. ... tend to detract from this free sharing of knowledge, ... are you psychopatic or simply evil. ...
    (sci.physics)
  • Re: Calc. energy harmonics
    ... :> I will if you remember to mark text you quote. ... have a meaningul discussion with, ... at 10,000 mph pulling 35Gs on its way to Cape Canaveral, ...
    (sci.physics)
  • Re: Calc. energy harmonics
    ... I will if you remember to mark text you quote. ... Draw you own conclusons about this poster. ... Harry C. ...
    (sci.physics)