Now I have a JSON string in bash:
str='{"output_name":"http://HOST:33445/data/results/merged_video.mp4"}'
And I got an ip address from a command:
HOST_IP_FOR_FUNC="$(minikube ssh "route -n | grep ^0.0.0.0 | awk '{ print \$2 }'")" && echo $HOST_IP_FOR_FUNC
The result is 192.168.64.1
.
I'd like to use this variable to replace "HOST" in str
.
So I used:
z=${str//HOST/$HOST_IP_FOR_FUNC} && echo $z
only got
:33445/data/results/merged_video.mp4"}
However, if I explicitly assign a value to the HOST_IP_FOR_FUNC:
ip="192.168.64.1"
z=${str//HOST/$ip} && echo $z
Then I got what I want:
{"output_name":"http://192.168.64.1:33445/data/results/merged_video.mp4"}
How can I deal with it?
I am using zsh or bash on MacOS 10.15.3
According to @Cyrus, I got the output of his suggested command:
minikube ssh "route -n | grep ^0.0.0.0 | awk '{ print \$2 }'" | hexdump -C
00000000 31 39 32 2e 31 36 38 2e 36 34 2e 31 0d 0a |192.168.64.1..|
0000000e