{"id":1278,"date":"2020-03-16T17:09:29","date_gmt":"2020-03-16T16:09:29","guid":{"rendered":"https:\/\/blog.airbjorn.de\/?p=1278"},"modified":"2020-03-16T17:09:30","modified_gmt":"2020-03-16T16:09:30","slug":"bash-looping-mit-whitespaces","status":"publish","type":"post","link":"https:\/\/blog.airbjorn.de\/?p=1278","title":{"rendered":"Bash-Looping mit Whitespaces"},"content":{"rendered":"\n<p>Manchmal m\u00f6chte man \u00fcber eine Datei oder eine Dateiliste _zeilenweise_ iterieren. Eine for-Schleife im Default f\u00fchrt aber zu einer wortweisen Iteration.<\/p>\n\n\n\n<p>Def\u00fcr gibt&#8217;s die Umgebungsvariable IFS, die f\u00fcr solche F\u00e4lle modifiziert werden kann.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"> IFS=$<strong>(echo<\/strong> -en \"<strong>\\n<\/strong>\\b\"<strong>)<\/strong><\/pre>\n\n\n\n<p>Wenn im Kontext dieses Variableninhalts in der bash mit einer for-Schleife iteriert wird, dann bekommt man ganze Zeilen zur\u00fcck.<\/p>\n\n\n\n<p>Siehe: <a href=\"https:\/\/www.cyberciti.biz\/tips\/handling-filenames-with-spaces-in-bash.html\">https:\/\/www.cyberciti.biz\/tips\/handling-filenames-with-spaces-in-bash.html<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Manchmal m\u00f6chte man \u00fcber eine Datei oder eine Dateiliste _zeilenweise_ iterieren. Eine for-Schleife im Default f\u00fchrt aber zu einer wortweisen Iteration. Def\u00fcr gibt&#8217;s die Umgebungsvariable IFS, die f\u00fcr solche F\u00e4lle modifiziert werden kann. IFS=$(echo -en &#8222;\\n\\b&#8220;) Wenn im Kontext dieses Variableninhalts in der bash mit einer for-Schleife iteriert wird, dann bekommt man ganze Zeilen zur\u00fcck. [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"ngg_post_thumbnail":0,"footnotes":""},"categories":[21],"tags":[],"class_list":["post-1278","post","type-post","status-publish","format-standard","hentry","category-linux"],"_links":{"self":[{"href":"https:\/\/blog.airbjorn.de\/index.php?rest_route=\/wp\/v2\/posts\/1278","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.airbjorn.de\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.airbjorn.de\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.airbjorn.de\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.airbjorn.de\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1278"}],"version-history":[{"count":1,"href":"https:\/\/blog.airbjorn.de\/index.php?rest_route=\/wp\/v2\/posts\/1278\/revisions"}],"predecessor-version":[{"id":1279,"href":"https:\/\/blog.airbjorn.de\/index.php?rest_route=\/wp\/v2\/posts\/1278\/revisions\/1279"}],"wp:attachment":[{"href":"https:\/\/blog.airbjorn.de\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1278"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.airbjorn.de\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1278"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.airbjorn.de\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1278"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}