{"id":11383,"date":"2024-06-25T12:16:00","date_gmt":"2024-06-25T17:16:00","guid":{"rendered":"https:\/\/www.rushworth.us\/lisa\/?p=11383"},"modified":"2025-01-27T12:29:55","modified_gmt":"2025-01-27T17:29:55","slug":"linux-command-column","status":"publish","type":"post","link":"https:\/\/www.rushworth.us\/lisa\/?p=11383","title":{"rendered":"Linux Command: Column"},"content":{"rendered":"\n<p>Column is an interesting command &#8211; it will turn delimited text into, well, <em>columns<\/em>. Simply tell it you want a table (-t) and indicate what separator to use (-s). Optionally, you can add table column headers<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n&#x5B;lisa@linux01 ~\/]# cat \/etc\/group | column -t -s :\nroot              x  0      root,lisa\nbin               x  1\ndaemon            x  2\n...\npassim            x  987\n\n<\/pre><\/div>\n\n\n<p>Alternately, you can use -J to get JSON-formatted output. Here you need the &#8211;table-columns as a comma delimited list of column names:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n&#x5B;lisa@linux01 ~\/]# cat \/etc\/group | column -J -s : --table-columns &quot;group,password,gid,members&quot;\n{\n   &quot;table&quot;: &#x5B;\n      {\n         &quot;group&quot;: &quot;root&quot;,\n         &quot;password&quot;: &quot;x&quot;,\n         &quot;gid&quot;: &quot;0&quot;,\n         &quot;members&quot;: &quot;root,lisa&quot;\n      },{\n         &quot;group&quot;: &quot;bin&quot;,\n         &quot;password&quot;: &quot;x&quot;,\n         &quot;gid&quot;: &quot;1&quot;,\n         &quot;members&quot;: null\n      },{\n         &quot;group&quot;: &quot;daemon&quot;,\n         &quot;password&quot;: &quot;x&quot;,\n         &quot;gid&quot;: &quot;2&quot;,\n         &quot;members&quot;: null\n      },{\n         &quot;group&quot;: &quot;passim&quot;,\n         &quot;password&quot;: &quot;x&quot;,\n         &quot;gid&quot;: &quot;987&quot;,\n         &quot;members&quot;: null\n      }\n   ]\n}\n\n<\/pre><\/div>\n\n\n<p>Which can then be parsed with jq<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n&#x5B;lisa@linux01 ~\/]# cat \/etc\/group | column -J -s : --table-columns &quot;group,password,gid,members&quot; | jq &#039;&#x5B;.table&#x5B;] | {group: .group, members: .members}]&#039;\n&#x5B;\n  {\n    &quot;group&quot;: &quot;root&quot;,\n    &quot;members&quot;: &quot;root,lisa&quot;\n  },\n  {\n    &quot;group&quot;: &quot;bin&quot;,\n    &quot;members&quot;: null\n  },\n  {\n    &quot;group&quot;: &quot;daemon&quot;,\n    &quot;members&quot;: null\n  },\n  {\n    &quot;group&quot;: &quot;passim&quot;,\n    &quot;members&quot;: null\n  }\n]\n\n<\/pre><\/div>","protected":false},"excerpt":{"rendered":"<p>Column is an interesting command &#8211; it will turn delimited text into, well, columns. Simply tell it you want a table (-t) and indicate what separator to use (-s). Optionally, you can add table column headers Alternately, you can use -J to get JSON-formatted output. Here you need the &#8211;table-columns as a comma delimited list &hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[30],"tags":[2007,47,294,1195],"class_list":["post-11383","post","type-post","status-publish","format-standard","hentry","category-system-administration","tag-command-line","tag-fedora","tag-linux","tag-redhat"],"_links":{"self":[{"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=\/wp\/v2\/posts\/11383","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=11383"}],"version-history":[{"count":1,"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=\/wp\/v2\/posts\/11383\/revisions"}],"predecessor-version":[{"id":11384,"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=\/wp\/v2\/posts\/11383\/revisions\/11384"}],"wp:attachment":[{"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=11383"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=11383"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=11383"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}