Ubuntu: Run the output of another command

You seem to have worked this out yourself, but you can use:

$(command parameter1 parameter2)

Edit of edit: the below is somewhat wrong, whilst it does run the command in a subshell, it turns out that the environment variables will still be available. Sorry for misleading people...

Edit: that will run in a subshell, any unexported environment variables won't be used. If you want to run a command in the same shell, you need to use:

eval $(command parameter1 parameter2)

Another answer given is to pipe through bash itself:

echo 'uname -a' | bash 

That will also execute in a subshell, to run in the same shell you will need:

echo 'uname -a' | bash -c

Incidentally, you can also use back ticks instead of the $() syntax, but it's not recommended.


Use this:

commandlineA param1 param2 | bash

Example:

echo "uname -a" | bash

Output:

Linux k1104 2.6.38-8-generic #42-Ubuntu SMP Mon Apr 11 03:31:50 UTC 2011 i686 i686 i386 GNU/Linux