How to join every two lines of a text file ?

triapthisuresh
Posts: 133
Joined: Fri Aug 12, 2016 1:17 pm

How to join every two lines of a text file ?

Postby triapthisuresh » Fri Aug 12, 2016 7:13 pm

Can some one help me to join every two lines of a text file?

amit.g512
Posts: 81
Joined: Fri Aug 12, 2016 6:55 pm

Re: How to join every two lines of a text file ?

Postby amit.g512 » Fri Aug 12, 2016 7:14 pm

Please try awk one-liner to join every two lines of a text file

awk '{ if ( ( NR % 2 ) == 0 ) { printf("%s\n",$0) } else { printf("%s ",$0) } }' file


Return to “Scripting”

Who is online

Users browsing this forum: No registered users and 1 guest