{"id":5346,"date":"2019-06-14T19:07:08","date_gmt":"2019-06-15T00:07:08","guid":{"rendered":"https:\/\/www.rushworth.us\/lisa\/?p=5346"},"modified":"2019-06-14T19:09:33","modified_gmt":"2019-06-15T00:09:33","slug":"iterating-through-files-folders-with-spaces-in-name-using-find-in-bash","status":"publish","type":"post","link":"https:\/\/www.rushworth.us\/lisa\/?p=5346","title":{"rendered":"Iterating through files\/folders with spaces in name using find in bash"},"content":{"rendered":"<p>Ran into a problem using Sphinx to document some Python modules and scripts that Scott put together for OpenHAB. They&#8217;re making some changes to the files to get Sphinx to process them, thus making <em>copies<\/em> of the original code. Problem is, some of the folders just weren&#8217;t showing up in the copy. Needed to change IFS in order to tokenize the find results into full paths that <em>don&#8217;t<\/em> break on spaces in file or folder names.<\/p>\n<pre>SAVEDIFS=$IFS\r\nIFS=$(echo -en \"\\n\\b\")\r\n\r\nfor DIRNAME in $(find \"$COMMUNITY_DIR\" -maxdepth 1 -type d 2&gt;\/dev\/null); do\r\n     echo $DIRNAME\r\ndone\r\nIFS=$SAVEDIFS<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Ran into a problem using Sphinx to document some Python modules and scripts that Scott put together for OpenHAB. They&#8217;re making some changes to the files to get Sphinx to process them, thus making copies of the original code. Problem is, some of the folders just weren&#8217;t showing up in the copy. Needed to change &hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[33],"tags":[632,781,294],"class_list":["post-5346","post","type-post","status-publish","format-standard","hentry","category-coding","tag-bash","tag-ifs","tag-linux"],"_links":{"self":[{"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=\/wp\/v2\/posts\/5346","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=5346"}],"version-history":[{"count":2,"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=\/wp\/v2\/posts\/5346\/revisions"}],"predecessor-version":[{"id":5348,"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=\/wp\/v2\/posts\/5346\/revisions\/5348"}],"wp:attachment":[{"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=5346"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=5346"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=5346"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}