[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Help-bash] How pass arguments to a command run by the -c option of
From: |
Ken Irving |
Subject: |
Re: [Help-bash] How pass arguments to a command run by the -c option of bash? |
Date: |
Sun, 21 Jul 2013 08:06:53 -0800 |
User-agent: |
Mutt/1.5.20 (2009-06-14) |
On Sun, Jul 21, 2013 at 11:01:45AM -0500, Peng Yu wrote:
> Hi,
>
> I'm trying to run a command by the -c option. But 'a' is not passed to
> address@hidden Does anybody know what is correct way to pass the command
> arguments to a command run by the -c option of bash?
>
> ~$ bash -c 'echo x $@' a b c
> x b c
$ bash -c 'echo x $0 $@' a b c
x a b c
>From bash(1):
-c string If the -c option is present, then commands are
read from string. If there are arguments after the
string, they are assigned to the positional parameters,
starting with $0.
So,
$ bash -c 'echo x $0 $@' a b c
x a b c
Ken