{"id":622,"date":"2010-03-17T23:53:32","date_gmt":"2010-03-17T13:53:32","guid":{"rendered":"http:\/\/www.erisian.com.au\/wordpress\/?p=622"},"modified":"2010-03-17T23:57:15","modified_gmt":"2010-03-17T13:57:15","slug":"the-simple-scripts-in-life-are-often-the-best","status":"publish","type":"post","link":"https:\/\/www.erisian.com.au\/wordpress\/2010\/03\/17\/the-simple-scripts-in-life-are-often-the-best","title":{"rendered":"The simple scripts in life are often the best"},"content":{"rendered":"<p>Possibly my longest blog post title ever?<\/p>\n<p>Anyway, here&#8217;s a link to today&#8217;s little bit of scripting. I&#8217;ve now written this script three or four times, so I figure that means it&#8217;s useful and maybe worth keeping around. I&#8217;m calling it <a href=\"http:\/\/junkcode.erisian.com.au\/dir2tree\">dir2tree<\/a> and all it does is take a (sorted) list of pathnames and convert it into a tree structure. So, eg:<\/p>\n<blockquote><p><code><\/p>\n<pre>$ dpkg -L samba | grep man.*gz\r\n\/usr\/share\/man\/man8\/mksmbpasswd.8.gz\r\n\/usr\/share\/man\/man8\/eventlogadm.8.gz\r\n\/usr\/share\/man\/man8\/tdbbackup.8.gz\r\n\/usr\/share\/man\/man8\/pdbedit.8.gz\r\n\/usr\/share\/man\/man8\/smbd.8.gz\r\n\/usr\/share\/man\/man8\/nmbd.8.gz\r\n\/usr\/share\/man\/man1\/smbstatus.1.gz\r\n\/usr\/share\/man\/man1\/profiles.1.gz\r\n\/usr\/share\/man\/man1\/smbcontrol.1.gz<\/pre>\n<p><\/code>\n<\/p><\/blockquote>\n<p>becomes<\/p>\n<blockquote><p><code><\/p>\n<pre>$ dpkg -L samba | grep man.*gz | sort | dir2tree\r\n\/\r\n\tusr\/\r\n\t\tshare\/\r\n\t\t\tman\/\r\n\t\t\t\tman1\/\r\n\t\t\t\t\tprofiles.1.gz\r\n\t\t\t\t\tsmbcontrol.1.gz\r\n\t\t\t\t\tsmbstatus.1.gz\r\n\t\t\t\tman8\/\r\n\t\t\t\t\teventlogadm.8.gz\r\n\t\t\t\t\tmksmbpasswd.8.gz\r\n\t\t\t\t\tnmbd.8.gz\r\n\t\t\t\t\tpdbedit.8.gz\r\n\t\t\t\t\tsmbd.8.gz\r\n\t\t\t\t\ttdbbackup.8.gz<\/pre>\n<p><\/code>\n<\/p><\/blockquote>\n<p>So yeah. There you go.<\/p>\n<p>(A related useful tool is <a href=\"http:\/\/packages.debian.org\/tree\">tree<\/a>, which generates a prettier tree and does the directory walking itself. I wanted something that I could use with find, and I couldn&#8217;t spot anything that already existed.)<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Possibly my longest blog post title ever? Anyway, here&#8217;s a link to today&#8217;s little bit of scripting. I&#8217;ve now written this script three or four times, so I figure that means it&#8217;s useful and maybe worth keeping around. I&#8217;m calling it dir2tree and all it does is take a (sorted) list of pathnames and convert [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[16],"tags":[20],"_links":{"self":[{"href":"https:\/\/www.erisian.com.au\/wordpress\/wp-json\/wp\/v2\/posts\/622"}],"collection":[{"href":"https:\/\/www.erisian.com.au\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.erisian.com.au\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.erisian.com.au\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.erisian.com.au\/wordpress\/wp-json\/wp\/v2\/comments?post=622"}],"version-history":[{"count":3,"href":"https:\/\/www.erisian.com.au\/wordpress\/wp-json\/wp\/v2\/posts\/622\/revisions"}],"predecessor-version":[{"id":625,"href":"https:\/\/www.erisian.com.au\/wordpress\/wp-json\/wp\/v2\/posts\/622\/revisions\/625"}],"wp:attachment":[{"href":"https:\/\/www.erisian.com.au\/wordpress\/wp-json\/wp\/v2\/media?parent=622"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.erisian.com.au\/wordpress\/wp-json\/wp\/v2\/categories?post=622"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.erisian.com.au\/wordpress\/wp-json\/wp\/v2\/tags?post=622"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}