Get line number in flat file

Hi,

Is there a way to find out the line number from where the data starts?
like if the data contains column header, irrespective of the text in the column header we should get the line number from which contains the column header.

I am sorry if I haven't explained the problem clearly.

Thanks

Can you show sample input file?

here the column header is

so I want to get the line number that contains the header, it should be generic

Thanks

Is it always second non-empty line header?

no, its not like that, it keeps changing from file to file, some times the column header comes in the 1st line itself and sometimes in the line 2 or 3 and so on...

awk '/^Pcode/{print NR;exit}' yourfile

I assumed "ACCENT_INPUT" is your first line in your file. So asked whether second non-empty line "Pcode Dealer Name Comp INF" header.

Is this "ACCENT_INPUT" file name or first line in your file?

If your first non-empty line is header, then try this

awk ' ! /^$/ { print NR; exit } ' file

If the column header is in first line then the code works, otherwise it is printing the result as 1, whereas the column header is in line 4

awk '/^[[:blank:]]*Pcode/{print NR;exit}' yourfile