Executing a command named in a variable

Nils Kassube kassube at gmx.net
Tue Dec 1 11:45:31 UTC 2009


Loïc Grenié wrote:
> 2009/12/1 Nils Kassube <kassube at gmx.net>:
> > Ray Parrish wrote:
> >> Would the following work?
> >>
> >> # set variable to command line
> >> ExecuteEditor="/usr/bin/gedit filename.ext"
> >> # execute external command.
> >> $ExecuteEditor &
> >
> > No, it wouldn't work because bash will look in /usr/bin for a
> > command "gedit filename.ext" which doesn't exist. You would need
> > the eval command here but you might as well write it this way:
> 
>     Did you try before answering ? It works.


Sorry, yes, it does work if I try it. And no, I didn't try it before.


Nils




More information about the ubuntu-users mailing list