{"id":143,"date":"2024-09-29T07:32:28","date_gmt":"2024-09-29T06:32:28","guid":{"rendered":"http:\/\/monkey.ploogie.co.uk\/?page_id=143"},"modified":"2026-01-08T04:46:50","modified_gmt":"2026-01-08T04:46:50","slug":"mwnci-cat-function","status":"publish","type":"page","link":"https:\/\/monkey.ploogie.co.uk\/index.php\/mwnci-cat-function\/","title":{"rendered":"Mwnci cat() Function"},"content":{"rendered":"<h2><span id=\"Syntax\" class=\"mw-headline\">Syntax<\/span><\/h2>\n<p>cat(<i><b>filename<\/b><\/i>)<br \/>\nbzcat(<i><b>filename<\/b><\/i>)<br \/>\ngzcat(<i><b>filename<\/b><\/i>)<\/p>\n<h2><span id=\"Description\" class=\"mw-headline\">Description<\/span><\/h2>\n<p>The\u00a0<i>cat()<\/i>\u00a0function returns the contents of file\u00a0<i>filename<\/i>\u00a0as a single string. <i>cat()<\/i> makes an initial check of the file contents before reading and will use the appropriate inner function to read the contents. That is <i>bzcat()<\/i> or <i>gzcat()<\/i> will be used to read a file, depending on the compression method.<\/p>\n<p>\nThe <i>cat()<\/i>, <i>bzcat()<\/i>, and <i>gzcat()<\/i> built-ins can be used separately should you not want to rely on <i>cat()<\/i> to discerninmg the file contents\/type.<\/p>\n<h2><span id=\"Example\" class=\"mw-headline\">Example<\/span><\/h2>\n<pre>filename=\"\/etc\/passwd\"\r\nlines=split(cat(filename), \"\\n\")   \/\/split the single string by newline\r\nforeach line in lines {\r\n    println(line)\r\n}\r\n\r\n...\r\n...\r\nnobody:x:65534:65534:nobody:\/nonexistent:\/usr\/sbin\/nologin\r\nsystemd-timesync:x:100:102:systemd Time Synchronization,,,:\/run\/systemd:\/usr\/sbin\/nologin\r\nsystemd-network:x:101:103:systemd Network Management,,,:\/run\/systemd:\/usr\/sbin\/nologin\r\n...\r\n...\r\n\r\n\r\n\/\/ A simpler version\r\nprint(cat(\"\/etc\/passwd\"))\r\n\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Syntax cat(filename) bzcat(filename) gzcat(filename) Description The\u00a0cat()\u00a0function returns the contents of file\u00a0filename\u00a0as a single string. cat() makes an initial check of the file contents before reading and will use the appropriate inner function to read the contents. That is bzcat() or gzcat() will be used to read a file, depending on the compression method. The cat(), &hellip; <a href=\"https:\/\/monkey.ploogie.co.uk\/index.php\/mwnci-cat-function\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Mwnci cat() Function&#8221;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-143","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/monkey.ploogie.co.uk\/index.php\/wp-json\/wp\/v2\/pages\/143","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/monkey.ploogie.co.uk\/index.php\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/monkey.ploogie.co.uk\/index.php\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/monkey.ploogie.co.uk\/index.php\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/monkey.ploogie.co.uk\/index.php\/wp-json\/wp\/v2\/comments?post=143"}],"version-history":[{"count":3,"href":"https:\/\/monkey.ploogie.co.uk\/index.php\/wp-json\/wp\/v2\/pages\/143\/revisions"}],"predecessor-version":[{"id":1277,"href":"https:\/\/monkey.ploogie.co.uk\/index.php\/wp-json\/wp\/v2\/pages\/143\/revisions\/1277"}],"wp:attachment":[{"href":"https:\/\/monkey.ploogie.co.uk\/index.php\/wp-json\/wp\/v2\/media?parent=143"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}