Use semicolons not , between awk commands Tomas
On Thu, Jan 11, 2024, 10:30 Rich Shepard <rshep...@appl-ecosys.com> wrote: > I have a file with two-line paragraphs and want to extract only the first > line of each paragraph to an output file. Sample input file: > line 1 > line 2 > > line 1 > line 2 > > line 1 > line 2 > > I thought the awk 'next' statement would do this but my attempts failed. > For example: > $ gawk '{ print $0, next, next }' testfile.txt > out.txt > gawk: cmd. line:1: { print $0, next, next } > gawk: cmd. line:1: ^ syntax error > gawk: cmd. line:1: { print $0, next, next } > gawk: cmd. line:1: ^ syntax error > > and > > $ gawk '{ print $0, \n, \n }' testfile.txt > out.txt > gawk: cmd. line:1: { print $0, \n, \n } > gawk: cmd. line:1: ^ backslash not last character on line > gawk: cmd. line:1: { print $0, \n, \n } > gawk: cmd. line:1: ^ syntax error > > I didn't find an example in my SED AWK book or my web searches. I'm sure > there must be a way to do this and I'd like to learn how. > > TIA, > > Rich >