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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to display field number where string is matched 1

Status
Not open for further replies.

mrr

Technical User
May 3, 2001
67
US
How can I simply use the results of a match or index(substr function to find out the field number where the match is found?
I want to increment by one to this result and then store in a variable the next field values inorder to print later.

Thanks
 
A starting point:
Code:
awk '{for(i=1;i<=NF;++i)if(match($i,/yourPattern/))print FNR,i,$i,$(i+1)}' /path/to/input

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top