2

I have a kind of "bash newbie" question: how do I pass the result output of one command to exec. The result of the first command is the name of other command, so exec should be able to execute it.

lwt
  • 23

1 Answers1

1

Use command substitution. A contrived (and rather useless) example:

exec $(echo whoami)

The $(…) will be replaced with the output of the command within. There's also the variant with backticks (`), but it's not recommended for various reasons.

slhck
  • 235,242