I have a string "rtcpOnNbActive true"
stored in a variable x
. I want to extract "true" as substring and store in a variable. How can I do this?
Bash – Extracting the second word from a string variable
bashstringvariable
bashstringvariable
I have a string "rtcpOnNbActive true"
stored in a variable x
. I want to extract "true" as substring and store in a variable. How can I do this?
Best Answer
Try this way:
echo $x
display the value ofx
.awk '{print $2}'
prints the second field of the previously displayedx
.$(
...)
hold the output and let assign it toy
.