You're viewing a comment by Jeff and its responses.

Jeff Permalink
August 19, 2016, 11:50

Hi there, I need a little help.

I have a file (hostlist.txt) that contains the following sample,

BA6648 Apps:InforMS
BA12105 MKT-TEST
BA8574 GAB:Global Big Company
BA13398 Test:LnHndlrDev
BA13848 DXRY:Fire
BA28278 HAPA:ds-28
.... etc

and basically wish to look up the BA reference in the file, and lookup the complete string after the space, so I've used initially....

appId=`grep -i ba6648 hostlist.txt | awk '{print $2}'`
echo $appId

which gives me the result "Apps:InforMS"

BUT when I look up...

appId=`grep -i ba8574 hostlist.txt | awk '{print $2}'`

I get "GHP:Global" but I really need "GHP:Global Big Company"

So, how can I extract everything from $2 to the end of the line with awk?

Thank you in advance,

Jeff

Reply To This Comment

(why do I need your e-mail?)

(Your twitter handle, if you have one.)

Type the word "cloud_122": (just to make sure you're a human)

Please preview the comment before submitting to make sure it's OK.