How to increment line counter for line beginning replacements by AWK/...?
9
votes
4
answers
3823
views
I first thought about SED (
sed "s/^/COUNTER \&/" /tmp/1.tex
) but it is designed for a single line, and I cannot increment the counter itself by sed so thinking now awk
because I have great experiences with gawk
in integrated approaches.
Data
What & South Dragon & North Dragon & 5 \\ \hline
What & South Dragon & North Dragon & 5 \\ \hline
What & South Dragon & North Dragon & 5 \\ \hline
Expected output
1 & What & South Dragon & North Dragon & 5 \\ \hline
2 & What & South Dragon & North Dragon & 5 \\ \hline
3 & What & South Dragon & North Dragon & 5 \\ \hline
OS: Debian 8.5
Asked by Léo Léopold Hertz 준영
(7138 rep)
Dec 27, 2016, 07:59 PM
Last activity: Dec 30, 2016, 12:57 PM
Last activity: Dec 30, 2016, 12:57 PM