Print line numbers starting at zero using awk

Viewed 150341

Can anyone tell me how to print line numbers including zero using awk?

Here is my input file stackfile2.txt

when I run the below awk command I get actual_output.txt

awk '{print NR,$0}' stackfile2.txt | tr " ", "," > actual_output.txt

whereas my expected output is file.txt

How do I print the line numbers starting with zero (0)?

4 Answers
Related