Hello,
I have a question on how to find the line number of the first column that contains specific data. I know how to print all the line numbers of those columns, but haven't been able to figure out how to print only the first one that is found.
For example, if my data has four columns:
115 34 8 0
85 112 97 0
147 77 70 0
136 35 9 0
130 31 9 0
171 120 64 1
180 141 78 1
135 87 119 1
97 130 80 1
135 177 89 1
I want to scan the file till I get to the line which has '1' in the fourth column and then print out the line number at that point, and then exit. This is what I have so far:
awk -F " " '{if($4 == "1") print NR}' filename
Is there a way to do this without using awk as well?
Thanks!