in reply to How can I make it to a one liner
Treat "," as the end of line marker (-054).
Every third line ($. % 3 == 0),
change the trailing comma to a newline (s/,/\n/).
Print the result (-p).
perl -054pe"$.%3||s/,/\n/"
In action:
>echo a,b,c,d,e,f,g,h,i | perl -054pe"$.%3||s/,/\n/" a,b,c d,e,f g,h,i
Update: As moritz points out, I assumed all the input is on one line.
|
|---|