Reputation: 3156
I am having a problem like this;
root@B056HAP2865372:~# str="$(consul-template --version)"
consul-template v0.18.1 (9c62737)
root@B056HAP2865372:~# echo $str
root@B056HAP2865372:~# consul-template --version | cut -d" " -f 2
consul-template v0.18.1 (9c62737)
so the command $consul-template --version
works, but I cant assign it to any variable or pipe it to some other command.
If it helps this machine is a LXC 2.9.3
container.
It's a bash shell.
I have no idea what I am doing wrong.
Upvotes: 1
Views: 37
Reputation: 786091
Your command is writing it on stderr
. You can redirect stderr to stdout and then assign to a variable:
str="$(consul-template --version 2>&1)"
Upvotes: 1