eval in bash

eval in bash

am 19.09.2007 07:32:27 von nits

What exactly is the need of eval command in bash. As an example for
eval tldp.org-bash guide its given
y=`eval ls -l`
echo "$y"

But, even if we give y=`ls -l`
echo "$y"
it gives the same result. The special symbol " ` " is for command
substitution ?

Re: eval in bash

am 19.09.2007 09:15:06 von dozzie

On 19.09.2007, nits wrote:
> What exactly is the need of eval command in bash. As an example for
> eval tldp.org-bash guide its given
> y=`eval ls -l`
> echo "$y"
>
> But, even if we give y=`ls -l`
> echo "$y"
> it gives the same result.

Try
y='ls -l'
eval "$y"

> The special symbol " ` " is for command
> substitution ?

It substitutes command output for the whole `...` string.

--
Secunia non olet.
Stanislaw Klekot