I have a file which looks like this:
1
2
AA
4
5
AA BB
7
8
AA BB CC
10
11
AA BB CC DD
I am using awk to extract only every nth line where n=3.
>>awk 'NR%3==0' /input/file_foo >> output/file_foobar
The output is appearing in a single line as:
AA AA BB AA BB CC AA BB CC DD
…..and so on
I want it to appear as:
AA
AA BB
AA BB CC
AA BB CC DD
I tried using \n, printf with \n, and so on but it doesn’t work as I expect. Please advise.
A verbose way,
Also you can use
{printf("%s\n\n", $0)}too. if single\ndoes not work.If it still does not work you might need to check the line terminator. It may not be proper. Use the
RSvariable inawkto separate on the unusual line terminator.