{"id":105,"date":"2013-07-26T22:24:45","date_gmt":"2013-07-27T02:24:45","guid":{"rendered":"http:\/\/jonesling.us\/blog\/?p=105"},"modified":"2013-07-28T10:30:59","modified_gmt":"2013-07-28T14:30:59","slug":"working-with-hidden-files-and-directories","status":"publish","type":"post","link":"https:\/\/blog.jonesling.us\/?p=105","title":{"rendered":"Working with hidden files and directories"},"content":{"rendered":"<p>I had a problem.\u00a0 My home directory is huge &#8211; 9 gigs &#8211; but I don&#8217;t know what&#8217;s taking up all that room. My porn stash is on another partition where my wife doesn&#8217;t know to look, so something is taking up a lot of room and I want to know what and why.<\/p>\n<p>Oh yeah, I know how to check the size of a directory &#8211; use <a title=\"'du' manual page\" href=\"http:\/\/linux.die.net\/man\/1\/du\" target=\"_blank\">du<\/a> (<code>'du -sh .'<\/code>) for the usage of current directory (including all sub directories).\u00a0 And, to see the size for every individual directory in the current directory, <code>'du -sh *'<\/code>.\u00a0 Easy peasy.<\/p>\n<p>But that didn&#8217;t tell me what I needed to know, since the total size of all visible directories was less than a quarter of the used space.\u00a0 That&#8217;s where hidden directories come into play.<\/p>\n<p>Now, in the unix world, there isn&#8217;t a special file permission to hide a file or directory.\u00a0 You just name it with a leading dot, like <code>'.my_hidden_stuff'<\/code>, and most utilities won&#8217;t display it.\u00a0 There&#8217;s nothing intrinsically hidden about it, though.\u00a0 You can view them easily enough, e.g. <code>'ls -a'<\/code> will show everything, including the &#8220;hidden&#8221; stuff.<\/p>\n<p>What if you want to see just the hidden stuff?\u00a0 It&#8217;s not as simple as saying <code>'ls -a .*'<\/code>, since that includes <code>'.'<\/code> (the current directory) and <code>'..'<\/code> (the parent directory), too.\u00a0 Some utilities, like <code>du<\/code>, will then combine arguments with a common root, which means you get the summary for the current directory, but none of the hidden files broken out.<\/p>\n<p><strong>Solution<\/strong><\/p>\n<p>In bash, at least, you can include simple regular expressions on the command line.\u00a0 (Remember, in unix, your command line is pre-processed by the shell (bash, csh, tcsh, etc.) and the expanded items are given to the program. DOS\/Windows, by contrast, the expansion and processing is the responsibility of the program and command.com (or cmd.exe) does little processing itself.<\/p>\n<p>The regex for all dot files, minus &#8216;.&#8217; and &#8216;..&#8217;, is <code>'.[^.]*'<\/code> (which basically says, &#8220;start with a dot, and the next character must exist but cannot be a dot, and then anything goes after that&#8221;).<\/p>\n<p>So, my command to see how much space each of my hidden directories are using, is<\/p>\n<p><code>du -shx .[^.]*<\/code><\/p>\n","protected":false},"excerpt":{"rendered":"<p>I had a problem.\u00a0 My home directory is huge &#8211; 9 gigs &#8211; but I don&#8217;t know what&#8217;s taking up all that room. My porn stash is on another partition where my wife doesn&#8217;t know to look, so something is taking up a lot of room and I want to know what and why. Oh &hellip; <a href=\"https:\/\/blog.jonesling.us\/?p=105\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Working with hidden files and directories&#8221;<\/span><\/a><\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_crdt_document":"","wprm-recipe-roundup-name":"","wprm-recipe-roundup-description":"","advanced_seo_description":"","jetpack_seo_html_title":"","jetpack_seo_noindex":false,"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[9],"tags":[],"class_list":["post-105","post","type-post","status-publish","format-standard","hentry","category-linux"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p4o3FW-1H","jetpack-related-posts":[],"jetpack_likes_enabled":true,"_links":{"self":[{"href":"https:\/\/blog.jonesling.us\/index.php?rest_route=\/wp\/v2\/posts\/105","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.jonesling.us\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.jonesling.us\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.jonesling.us\/index.php?rest_route=\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.jonesling.us\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=105"}],"version-history":[{"count":4,"href":"https:\/\/blog.jonesling.us\/index.php?rest_route=\/wp\/v2\/posts\/105\/revisions"}],"predecessor-version":[{"id":108,"href":"https:\/\/blog.jonesling.us\/index.php?rest_route=\/wp\/v2\/posts\/105\/revisions\/108"}],"wp:attachment":[{"href":"https:\/\/blog.jonesling.us\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=105"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.jonesling.us\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=105"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.jonesling.us\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=105"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}