Am using Windows 7 & gawk 3.1.3 (via UnxUtils).
I’d like to turn this input (Liverpool FC’s fixtures):
Sunday, 27 November 2011
Barclays Premier League
Liverpool v Man City, 16:00
Tuesday, 29 November 2011
Carling Cup
Chelsea v Liverpool, QF, 19:45
...
into a tab-separated file, such as:
Sunday, 27 November 2011<tab>Barclays Premier League<tab>Liverpool v Man City, 16:00
Tuesday, 29 November 2011<tab>Carling Cup<tab>Chelsea v Liverpool, QF, 19:45
...
I’ve tried doing this with awk, but failed thus far. Identifying every first and second line is easy enough:
if (NR % 3 == 1 || NR % 3 == 2) print;
but despite many attempts (usually resulting in syntax errors) can’t find out how to strip out the (Windows) line-endings and concatenate those with every third line.
I’m now wondering if awk is actually the right tool for the job.
Thanks for any pointers.
Should work. For every line where the modulo of
NR(number of records) is not 0 it will print the line and atabcharacter. Otherwise the (input) line and a newline character.HTH