How to run ampersand in commandline - BSD

This is a discussion on How to run ampersand in commandline - BSD ; Hi all, I'm trying to run a wget script that has an ampersand(&) in the URL and the shell is parsing the ampersand and putting a portion of the script into the background. Is there a trick to have the ...

+ Reply to Thread
Results 1 to 4 of 4

Thread: How to run ampersand in commandline

  1. How to run ampersand in commandline

    Hi all,

    I'm trying to run a wget script that has an ampersand(&) in the URL and
    the shell is parsing the ampersand and putting a portion of the script
    into the background.

    Is there a trick to have the shell ignore an ampersand?

    Thanks.

  2. Re: How to run ampersand in commandline

    On Tue, 02 May 2006 20:27:21 -0700, Johnny Kim wrote:

    > Hi all,
    >
    > I'm trying to run a wget script that has an ampersand(&) in the URL and
    > the shell is parsing the ampersand and putting a portion of the script
    > into the background.
    >
    > Is there a trick to have the shell ignore an ampersand?
    >
    > Thanks.


    I found a workaround. By putting a backslash in front of all the
    ampersands, a *nix shell won't parse the ampersand. I'm guessing that
    this will break with DOS compatibility. Oh well, c'est la vie.

  3. Re: How to run ampersand in commandline

    "Johnny Kim" wrote...
    > > Is there a trick to have the shell ignore an ampersand?
    > >
    > > Thanks.

    >
    > I found a workaround. By putting a backslash in front of all the
    > ampersands, a *nix shell won't parse the ampersand. I'm guessing that
    > this will break with DOS compatibility. Oh well, c'est la vie.


    You can also place the entire argument in single or double quotes and the
    shell will not interpret special characters (&, *, etc), compare:

    echo *
    echo "*"
    echo '*'
    echo $PATH
    echo "$PATH"
    echo '$PATH'

    I'm not sure what you mean by DOS compatibility though... Unix shells don't
    make any attempt to be compatible with DOS (why would they?).

    -- Nicholas.



  4. Re: How to run ampersand in commandline

    I usually just enclose the URL with single quotes. I use zsh.

    Johnny Kim said on 05/02/06 20:27:
    > Hi all,
    >
    > I'm trying to run a wget script that has an ampersand(&) in the URL and
    > the shell is parsing the ampersand and putting a portion of the script
    > into the background.
    >
    > Is there a trick to have the shell ignore an ampersand?
    >
    > Thanks.


+ Reply to Thread