Re: Bash Scripting Problem

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tuesday 20 May 2008 13:44:09 Heitor Moraes wrote:
> On Tue, May 20, 2008 at 2:31 PM, Thomas Kappelmueller
> <tkappelmueller@xxxxxxxxxxxxxxxx> wrote:
> > Example:
> > #!/bin/bash
> >
> > COMMAND='ls "test dir 1"'
> >
> > $COMMAND #have tried $($COMMAND), '$COMMAND'
> >
> > It always cuts it in half at the spaces.
> >
> > Error msg:
> > ls: cannot access "test: No such file or directory
> > ls: cannot access dir: No such file or directory
> > ls: cannot access 1": No such file or directory
> >
> > What am i not seeing?
>
> ` not '
> 
> COMMAND=`ls "test dir 1"`

I think the original poster meant that he had a directory (or file)
named "test dir 1".  If he does as you suggest, then the line

    $COMMAND

will no longer be a command, but the output of the command when the
original assignment was made.  That will result in an error.

The answer that suggested using

    eval $COMMAND

will do what I think the original poster intended.

-- 
Garry T. Williams --- +1 678 656-4579

-- 
fedora-list mailing list
fedora-list@xxxxxxxxxx
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list

[Index of Archives]     [Current Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]     [Fedora Docs]

  Powered by Linux