I have
$ cat awktestf
a++
b++
c++
I am doing and I get
cat awktestf | awk 'BEGIN { RS="++" ; OFS="@"; ORS="()" } { print $0 } END {print "I am done" }'
a()
b()
c()
()I am done()abc@abc:~$
My question is why am I getting an extra () at the end?
Even this does not work:
$ echo 'a++
> b++
> c++' | awk 'BEGIN { RS="++" ; OFS="@"; ORS="()" } { print $0 } END {print "I am done" }'
a()
b()
c()
()I am done()abc@abc:~$
ORSis appended to the end of each output record. Hence your “I am done” ends with().Misunderstood the question the first time.
This
translates to
After splitting into records using
RS, you get these recordsWhen you print them, each record is terminated with
ORS,(), soYou added “I am done”
Hence this is displayed as
(Since the last line does not end with a newline, your prompt shows on the same line)