Hi Elias,

Try this :

eval (grep file -e cmd: | cut -d: -f2)


On Thu, Mar 20, 2014 at 10:41 PM, Elias Assmann <elias.assm...@gmail.com>wrote:

> Hi,
>
> I ran into some trouble when I wanted to construct a command based on
> the contents of a file.  For the sake of the argument, let us say I have
>
>    > cat >file
>    junk
>    cmd: echo -e foo\nbar
>    trash
>
> and I want to run the part after 'cmd:' as a command.  How do you do
> this in fish?
>
> To elaborate, in bash I could do something like this
>
>    $ $(grep file -e cmd: | cut -d: -f2)
>    foo
>    bar
>
> but fish does not let me use '(...)' as a command:
>
>    > (grep file -e cmd: | cut -d: -f2)
>    fish: Illegal command name "(grep file -e cmd: | cut -d: -f2)"
>
> I also tried putting the command in by hand, and only getting the
> arguments from the external command, but that does not work either:
>
>    > echo (grep file -e cmd: | cut -d' ' -f3-)
>    -e foo\nbar
>
> apparently because '(...)' is interpreted as a single word.
>
> I am using fish 2.0.0.
>
>
>         Elias
>
>
> ------------------------------------------------------------------------------
> Learn Graph Databases - Download FREE O'Reilly Book
> "Graph Databases" is the definitive new guide to graph databases and their
> applications. Written by three acclaimed leaders in the field,
> this first edition is now available. Download your free book today!
> http://p.sf.net/sfu/13534_NeoTech
> _______________________________________________
> Fish-users mailing list
> Fish-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/fish-users
>



-- 
Regards,
Siteshwar
------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and their
applications. Written by three acclaimed leaders in the field,
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/13534_NeoTech
_______________________________________________
Fish-users mailing list
Fish-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/fish-users

Reply via email to