Re: bash syntax


Subject: Re: bash syntax
From: Arthur Corliss (arthur@corlissfamily.org)
Date: Sat Mar 30 2002 - 11:04:19 AKST


On Fri, 29 Mar 2002 bryan@ak.net wrote:

> First, I tried to alias the word quote to exactly the following:
> sed "s/'/\\\'/g"
> I tried a couple ways of putting the above in quotes, to make it
> a single string for alias. The best way seemed to be to use double
> quotes around the whole thing, and \ escape the existing two.
> Try it. Where the hell are those extra quotes coming from?

An easy work-around for that is to use an old vi trick: when you want to do
the following:

    alias filter='sed 's/foo/bar/g''

just press <CTRL> + V before any of the inner quotes, and that will tell the
shell to keep the quotes as literal part of the string. This will work with
escape sequences, newlines, etc. Try it on the command line, you'll see what
I mean.

        --Arthur Corliss
          Bolverk's Lair -- http://arthur.corlissfamily.org/
          Digital Mages -- http://www.digitalmages.com/
          "Live Free or Die, the Only Way to Live" -- NH State Motto



This archive was generated by hypermail 2a23 : Sat Mar 30 2002 - 10:55:38 AKST