i have a file, where measurement-data is stored in the first column. The file has also a header of 5 lines. I want to set counting up numbers [1, 2, 3, ...] in front of any particular measurement-value; should start at the 6. line with starting number 1.
i try to solve it with ...
awk 'NR > 6 { print FNR "\t" $0 }' file.dat
..but it will cut the header. Can someone give me a hint, how to give out the complete file?
Request you to please always do show sample input and expected sample output too. If I understood correctly your requirement, could you please try following and let me know if that helps.
###If you want to leave empty line.
awk 'NR > 6 && NF{ print ++i "\t" $0 }' Input_file
###If you want to count each line then following may help.
awk 'NR > 6 { print ++i "\t" $0 }' Input_file
thank you for the fast reply. Unfortunately your one-liner (both) work the same way and cut the top of the header like my awk-example, too. The given awk-one-liner, from the following threadpost, of RudiC work propper.
Thank you!
IMPe
---------- Post updated at 06:53 AM ---------- Previous update was at 06:51 AM ----------
Hi RudiC,
thanks a lot; Your one-liner is working propper and do exactly what i want.
Please try following it should print the headers too, not tested though.
###If you want to leave empty line.
awk 'NR==1{print;next} NR > 6 && NF{ print ++i "\t" $0 }' Input_file
###If you want to count each line then following may help.
awk 'NR==1{print;next} NR > 6 { print ++i "\t" $0 }' Input_file