How to force awk not to print a newline

I have two columns (fields) in my text file. I am trying to insert ‘|
FOO This is a description
BAR Another description for bar
TEXT Another description for TEXT

So I ran awk '{ print $1 "|"; $1=""; print}' input > output but print command is adding a new line:
FOO|
This is a description
BAR|
Another description for bar
TEXT|
Another description for TEXT

Is there any way to tell awk not to print a newline and create the file? Here is what I want so that I can create final HTML table based upon '|'
FOO|This is a description
BAR|Another description for bar
TEXT|Another description for TEXT

The post How to force awk not to print a newline appeared first on nixCraft.

I have two columns (fields) in my text file. I am trying to insert '|
FOO This is a description
BAR Another description for bar
TEXT Another description for TEXT

So I ran awk '{ print $1 "|"; $1=""; print}' input > output but print command is adding a new line:
FOO|
This is a description
BAR|
Another description for bar
TEXT|
Another description for TEXT

Is there any way to tell awk not to print a newline and create the file? Here is what I want so that I can create final HTML table based upon '|'
FOO|This is a description
BAR|Another description for bar
TEXT|Another description for TEXT

The post How to force awk not to print a newline appeared first on nixCraft.


Print Share Comment Cite Upload Translate
APA
() » How to force awk not to print a newline. Retrieved from https://www.truth.cx/2021/01/22/how-to-force-awk-not-to-print-a-newline/.
MLA
" » How to force awk not to print a newline." - , https://www.truth.cx/2021/01/22/how-to-force-awk-not-to-print-a-newline/
HARVARD
» How to force awk not to print a newline., viewed ,
VANCOUVER
- » How to force awk not to print a newline. [Internet]. [Accessed ]. Available from: https://www.truth.cx/2021/01/22/how-to-force-awk-not-to-print-a-newline/
CHICAGO
" » How to force awk not to print a newline." - Accessed . https://www.truth.cx/2021/01/22/how-to-force-awk-not-to-print-a-newline/
IEEE
" » How to force awk not to print a newline." [Online]. Available: https://www.truth.cx/2021/01/22/how-to-force-awk-not-to-print-a-newline/. [Accessed: ]
Select a language: