Reputation: 9649
How to use AWK
to transform the lines of linear format
to those of tabular format
? e.g. to change the format of Ubuntu versions from:
13.10
Saucy
Salamander
14.04
Trusty
Tahr
14.10
Utopic
Unicorn
to:
13.10,Saucy,Salamander
14.04,Trusty,Tahr
14.10,Utopic,Unicorn
Upvotes: 1
Views: 124
Reputation: 157957
I would use sed
for that:
sed 'N;N;s/\n/,/g' input.txt
The command reads a line and appends two additional lines to the pattern buffer N;N
. Then it replaces the newlines in between them by a ,
with s/\n/,/g
.
Upvotes: 1
Reputation: 203324
$ awk '{ORS=(NR%3?",":"\n")}1' file
13.10,Saucy,Salamander
14.04,Trusty,Tahr
14.10,Utopic,Unicorn
Upvotes: 3