I have a command which returns the below output. How can I write a script to extract mainhost and secondhost from this output and put it into an array? I may sometimes have more hosts like thirdhost. I am redirecting this output to a variable. So I guess there should be a awk or sed command to extract it. But I am not able to figure it out.I am using the below command, which prints the secondhost.How can I change it to print mainhost as well.
Thanks Scott for your quick reply. It works when I have mainhost and secondhost. Sometimes I will have more than two hosts like below. Its random and depends on the environment I am running. So how can I make it work whether it has 2 hosts or more.
If you're looking for your thread, I've renamed it to "Extracting text from within a section of text using AWK". "Scripting help" isn't very meaningful