AWK – print no newline

awk2Using awk to display information, the print function, by default, adds newline after each iteration. I wanted to copy the results and use them as an actual array in a program and preferred to have them all on one line, however. So printf had to be used instead of print:

awk '{printf "\"%s\", ", $1;}' file.txt

The result would be:

"value1", "value2", "value3", "value4", "value5", "value6"

which I could copy and use as an actual value of an array somewhere else.