{"id":18,"date":"2016-12-08T22:51:00","date_gmt":"2016-12-08T22:51:00","guid":{"rendered":"https:\/\/blog.kineteque.com\/?p=18"},"modified":"2016-12-08T22:51:00","modified_gmt":"2016-12-08T22:51:00","slug":"bash-script-to-issue-a-command-in-sub-directory","status":"publish","type":"post","link":"https:\/\/blog.kineteque.com\/?p=18","title":{"rendered":"Bash Script to Issue a Command in Sub-Directories"},"content":{"rendered":"<p>The way projects are organized at my current employer often requires me to run the same command in within the first level of sub-directories.<\/p>\n<p>For example, maybe I have to issue this command in\u00a0ten sub-directories:<\/p>\n<pre class=\"lang:sh decode:true\">git pull --rebase<\/pre>\n<p>This little script I wrote helps.<\/p>\n<pre class=\"lang:sh decode:true \">#!\/bin\/bash\n\necho \"input command to run on all sub-directories: \";\nread command; \nfor directory in .\/*\/; do \n   echo $directory $command; \n   cd $directory; \n   $command; \n   cd -; \ndone<\/pre>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The way projects are organized at my current employer often requires me to run the same command in within the first level of sub-directories. For example, maybe I have to issue this command in\u00a0ten sub-directories: git pull &#8211;rebase This little script I wrote helps. #!\/bin\/bash echo &#8220;input command to run on all sub-directories: &#8220;; read [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[12],"class_list":["post-18","post","type-post","status-publish","format-standard","hentry","category-bash","tag-bash"],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/blog.kineteque.com\/index.php?rest_route=\/wp\/v2\/posts\/18","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.kineteque.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.kineteque.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.kineteque.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.kineteque.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=18"}],"version-history":[{"count":0,"href":"https:\/\/blog.kineteque.com\/index.php?rest_route=\/wp\/v2\/posts\/18\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.kineteque.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=18"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.kineteque.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=18"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.kineteque.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=18"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}