{"id":541,"date":"2004-04-02T23:23:59","date_gmt":"2004-04-02T23:23:59","guid":{"rendered":"http:\/\/jasonbassford.com\/?p=541"},"modified":"2021-11-12T20:11:31","modified_gmt":"2021-11-13T01:11:31","slug":"the_magic_formu","status":"publish","type":"post","link":"https:\/\/www.jasonbassford.com\/index.php\/2004\/04\/02\/the_magic_formu\/","title":{"rendered":"The magic formula."},"content":{"rendered":"<p>Here&#8217;s a little Linux command line I came up with that keeps one directory having the same number of files in it as another directory &#8211; by deleting all of the oldest files until the file count is the same:<\/p>\n<p>ls \/etc\/assp\/spam -t | tail +$((`ls \/etc\/assp\/notspam | wc -l | sed -e &#8216;s\/^ *\/\/&#8217;`+1)) | xargs -i \/bin\/bash -c &#8220;rm \/etc\/assp\/spam\/{}&#8221;<\/p>\n<p>This will probably look like complete gibberish to most people.  I had to come up with it because of an issue I was having with the way that ASSP&#8217;s spam checking worked.  (If you look carefully enough, you&#8217;ll see some keywords in there that relate.)<\/p>\n<p>There isn&#8217;t really much point to this entry &#8211; other than that I&#8217;m a little proud to have assembled the above.<\/p>\n<p><b>Newsflash:<\/b> This is my 100th post!  (I knew that I&#8217;d be making one when I noticed that my last post was number 99 &#8211; I just didn&#8217;t know what it would be.)<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Here&#8217;s a little Linux command line I came up with that keeps one directory having the same number of files in it as another directory &#8211; by deleting all of the oldest files until the file count is the same: ls \/etc\/assp\/spam -t | tail +$((`ls \/etc\/assp\/notspam | wc -l | sed -e &#8216;s\/^ *\/\/&#8217;`+1)) &#8230;<\/p>\n<p><a href=\"https:\/\/www.jasonbassford.com\/index.php\/2004\/04\/02\/the_magic_formu\/\" class=\"more-link\">Continue reading &lsquo;The magic formula.&rsquo; &raquo;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-541","post","type-post","status-publish","format-standard","hentry","category-general"],"_links":{"self":[{"href":"https:\/\/www.jasonbassford.com\/index.php\/wp-json\/wp\/v2\/posts\/541"}],"collection":[{"href":"https:\/\/www.jasonbassford.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.jasonbassford.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.jasonbassford.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.jasonbassford.com\/index.php\/wp-json\/wp\/v2\/comments?post=541"}],"version-history":[{"count":0,"href":"https:\/\/www.jasonbassford.com\/index.php\/wp-json\/wp\/v2\/posts\/541\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.jasonbassford.com\/index.php\/wp-json\/wp\/v2\/media?parent=541"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.jasonbassford.com\/index.php\/wp-json\/wp\/v2\/categories?post=541"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.jasonbassford.com\/index.php\/wp-json\/wp\/v2\/tags?post=541"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}