{"id":1170,"date":"2014-12-16T21:16:43","date_gmt":"2014-12-16T20:16:43","guid":{"rendered":"https:\/\/www.hutsky.cz\/blog\/?p=1170"},"modified":"2014-12-28T15:53:12","modified_gmt":"2014-12-28T14:53:12","slug":"awk-print-no-newline","status":"publish","type":"post","link":"https:\/\/www.hutsky.cz\/blog\/2014\/12\/awk-print-no-newline\/","title":{"rendered":"AWK &#8211; print no newline"},"content":{"rendered":"<p><img loading=\"lazy\" decoding=\"async\" class=\"alignright size-full wp-image-1179\" src=\"https:\/\/www.hutsky.cz\/blog\/wp-content\/uploads\/awk2.png\" alt=\"awk2\" width=\"120\" height=\"106\" \/>Using <em>awk<\/em> to display information, the <em>print<\/em> 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 <em>printf<\/em> had to be used instead of <em>print<\/em>:<\/p>\n<pre>awk '{printf \"\\\"%s\\\", \", $1;}' file.txt<\/pre>\n<p>The result would be:<\/p>\n<pre>\"value1\", \"value2\", \"value3\", \"value4\", \"value5\", \"value6\"<\/pre>\n<p>which I could copy and use as an actual value of an array somewhere else.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Using 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, &hellip;<\/p>\n<p class=\"read-more\"> <a class=\"more-link\" href=\"https:\/\/www.hutsky.cz\/blog\/2014\/12\/awk-print-no-newline\/\"> <span class=\"screen-reader-text\">AWK &#8211; print no newline<\/span> Read More &raquo;<\/a><\/p>\n","protected":false},"author":4,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[43,18,41],"class_list":["post-1170","post","type-post","status-publish","format-standard","hentry","category-operatingsystems","tag-awk","tag-linux","tag-shell"],"_links":{"self":[{"href":"https:\/\/www.hutsky.cz\/blog\/wp-json\/wp\/v2\/posts\/1170","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.hutsky.cz\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.hutsky.cz\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.hutsky.cz\/blog\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hutsky.cz\/blog\/wp-json\/wp\/v2\/comments?post=1170"}],"version-history":[{"count":7,"href":"https:\/\/www.hutsky.cz\/blog\/wp-json\/wp\/v2\/posts\/1170\/revisions"}],"predecessor-version":[{"id":1180,"href":"https:\/\/www.hutsky.cz\/blog\/wp-json\/wp\/v2\/posts\/1170\/revisions\/1180"}],"wp:attachment":[{"href":"https:\/\/www.hutsky.cz\/blog\/wp-json\/wp\/v2\/media?parent=1170"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hutsky.cz\/blog\/wp-json\/wp\/v2\/categories?post=1170"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hutsky.cz\/blog\/wp-json\/wp\/v2\/tags?post=1170"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}