dagda1
dagda1

Reputation: 28770

output of command in string interpolation in bash

How can I echo the node location like this:

echo "node can be found at the following location ${which node}"

This results in a bad substitution error.

Upvotes: 2

Views: 1594

Answers (1)

nbari
nbari

Reputation: 26905

You could use:

echo "node can be found at the following location $(which node)"

$() is a subshell you could read more about it in this answer:

Upvotes: 3

Related Questions