Sep 5, 2006 #1 h3nd Programmer Jul 1, 2006 147 AU Hi guys, Probably this is simple, but I couldn't figure it out.. I would like to print the field number containing particular "word" for each line. How do I do that in awk or sed ? Thx guys,
Hi guys, Probably this is simple, but I couldn't figure it out.. I would like to print the field number containing particular "word" for each line. How do I do that in awk or sed ? Thx guys,
Sep 5, 2006 1 #2 olded Programmer Oct 27, 1998 1,065 US One way ... Code: awk ' { for(fieldno=1; fieldno<=NF; fieldno++) if($fieldno == "word") printf("%d\n", fieldno) } ' data.file Upvote 0 Downvote
One way ... Code: awk ' { for(fieldno=1; fieldno<=NF; fieldno++) if($fieldno == "word") printf("%d\n", fieldno) } ' data.file