{"id":397,"date":"2007-11-28T12:48:09","date_gmt":"2007-11-28T16:48:09","guid":{"rendered":"http:\/\/www.dr-chuck.com\/wordpress\/?p=397"},"modified":"2011-12-17T12:24:27","modified_gmt":"2011-12-17T16:24:27","slug":"nifty-c-shell-foreach-script-trick-for-spaces-with-file-names","status":"publish","type":"post","link":"https:\/\/www.dr-chuck.com\/csev-blog\/2007\/11\/nifty-c-shell-foreach-script-trick-for-spaces-with-file-names\/","title":{"rendered":"Nifty C-Shell foreach script Trick for spaces with file names"},"content":{"rendered":"<p>\nThis code did not work with files with spaces in the name:<\/p>\n<pre>\nforeach i ( `find . -name '*.java'` )\nls -l \"$i\"\n<\/pre>\n<p>\nThis code did work:<\/p>\n<pre>\nforeach ii ( `find . -name '*.java' | sed 's\/ \/@@@@\/g'` )\nset i=`echo $ii | sed 's\/@@@@\/ \/g'`\nls -l \"$i\"\n<\/pre>\n<p>\nI was quite pleased &#8211; I almost resorted to using walk in Python &#8211; but that was averted.  Somehow Sakai&#8217;s assignments tool (in mid semester) changed the format of the &#8220;Download all for grading&#8221; ZIP file.  I am sure it is an improvement &#8211; but it broke my C-Shell scripts I use for grading.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This code did not work with files with spaces in the name: foreach i ( `find . -name &#8216;*.java&#8217;` ) ls -l &#8220;$i&#8221; This code did work: foreach ii ( `find . -name &#8216;*.java&#8217; | sed &#8216;s\/ \/@@@@\/g&#8217;` ) set i=`echo $ii | sed &#8216;s\/@@@@\/ \/g&#8217;` ls -l &#8220;$i&#8221; I was quite pleased &#8211; I [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-397","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/www.dr-chuck.com\/csev-blog\/wp-json\/wp\/v2\/posts\/397","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.dr-chuck.com\/csev-blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.dr-chuck.com\/csev-blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.dr-chuck.com\/csev-blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.dr-chuck.com\/csev-blog\/wp-json\/wp\/v2\/comments?post=397"}],"version-history":[{"count":1,"href":"https:\/\/www.dr-chuck.com\/csev-blog\/wp-json\/wp\/v2\/posts\/397\/revisions"}],"predecessor-version":[{"id":2480,"href":"https:\/\/www.dr-chuck.com\/csev-blog\/wp-json\/wp\/v2\/posts\/397\/revisions\/2480"}],"wp:attachment":[{"href":"https:\/\/www.dr-chuck.com\/csev-blog\/wp-json\/wp\/v2\/media?parent=397"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.dr-chuck.com\/csev-blog\/wp-json\/wp\/v2\/categories?post=397"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.dr-chuck.com\/csev-blog\/wp-json\/wp\/v2\/tags?post=397"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}