I need to parse stdin in the following way:
(1) all newlines characters must be substituted with \n
(a literal \
followed by n
)
(2) nothing else should be performed except the previous
I chose awk
to do it, and I would like an answer that uses awk
if possible.
I came up with:
echo -ne "A\nB\nC" | awk '{a[NR]=$0;} END{for(i=1;i<NR;i++){printf "%s\\n",a[i];};printf "%s",a[NR];}'
But it looks cumbersome.
Is there a better / cleaner way?