Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Question on grabbing second word in a line

Status
Not open for further replies.

mcallaghan

IS-IT--Management
Mar 22, 2005
43
US
What my overall goal is to be able to grab the second word in a line from a awk command.

i have a line that shows the follow

test test123

what i am trying to do is just get the line test123

does anyone know of a awk command to get this.
 
I am very much uncertain with the proper syntax

Let me try going more into detail about this

We are pretty much passing a variable to this page

lets set the variable

section="test testabc"

I am trying to set a second variable from my section which is equal to "testabc" I would like to do this through either a sed a awk or even a cut.

section2="testabc"

I am kind of unclear on how to do that with what you gave me.
awk '{print $2}' infile > outfile


 
section2=$(echo "$section" | awk '{print $2}')

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top