So I am trying to extract an output similar to
x=($discover nginx --human=nood)
which gives me an output like
i-03099 nginx IP noodlefish pip b4b966d280546c6b070f5f952c281d3294308048
Further I want to extract the pip column in another variable.
When I do
echo "$x" | cut -f6
I get my desired output, but when I try.
y= "$x" | cut -f6
I get a blank output.
Please can you explain me why is this happening and how can I get the result I want. Thank you in advance.
Best Answer
That's weird, because this should not work, since
-f
should work only when fields are separated by TAB, unless-d
sets it otherwise.If you want to extract the field after the word
pip
, such script works for me