{"id":1840,"date":"2019-07-27T20:20:59","date_gmt":"2019-07-27T11:20:59","guid":{"rendered":"https:\/\/yuis-programming.com\/?p=1840"},"modified":"2021-07-19T12:14:55","modified_gmt":"2021-07-19T03:14:55","slug":"bash%e3%81%aeifsinternal-field-separator%e3%81%ab%e3%81%a4%e3%81%84%e3%81%a6","status":"publish","type":"post","link":"https:\/\/yuis-programming.com\/?p=1840","title":{"rendered":"Bash\u306eIFS(Internal Field Separator)\u306b\u3064\u3044\u3066"},"content":{"rendered":"<p>Linux\u30d1\u30bd\u30b3\u30f3\u30fb\u30b5\u30fc\u30d0\u30fc\u306e\u30b3\u30de\u30f3\u30c9\u30e9\u30a4\u30f3\u8a00\u8a9e\u3001Bash\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u8a00\u8a9e\u306eIFS(Internal Field Separator)\u306b\u3064\u3044\u3066\u7d39\u4ecb\u3057\u307e\u3059\u3002<\/p>\n<p>bash\u306b\u304a\u3044\u3066\u306eIFS\u3068\u3044\u3046\u5909\u6570\u306f\u3001for\u30eb\u30fc\u30d7\u306a\u3069\u3067\u4f7f\u7528\u3055\u308c\u308b\u30d5\u30a3\u30fc\u30eb\u30c9\u3092\u30bb\u30d1\u30ec\u30fc\u30c8\u3059\u308b\u30c7\u30ea\u30df\u30bf\u3092\u5909\u66f4\u3059\u308b\u3082\u306e\u3067\u3059\u3002<\/p>\n<p>\u3068\u3044\u3046\u306e\u3082\u3069\u3046\u3044\u3046\u3053\u3068\u304b\u3068\u3044\u3046\u3068\u3001bash\u306e<code>for in<\/code>\u304c\u4e00\u4f53\u3069\u3046\u3044\u3046\u57fa\u6e96\u3067\u6587\u5b57\u5217\u3092\u914d\u5217\u306b\u3057\u3066\u3044\u308b\u304b\u3068\u3044\u3046\u3053\u3068\u3092\u307e\u305a\u306f\u77e5\u3063\u3066\u304a\u304d\u307e\u3057\u3087\u3046\u3002<br \/>\nbash\u306e<code>for in<\/code>\u306e\u30c7\u30ea\u30df\u30bf\u306f\u3001<code>\\s<\/code> <code>\\t<\/code> <code>\\n<\/code>\u3067\u3059\u3002\u3064\u307e\u308a\u7a7a\u767d\u3001tab\u3001\u6539\u884c\u3001\u3067\u3059\u306d\u3002  ( \u50d5\u306f\u3053\u308c\u307e\u3067for\u306e\u30c7\u30ea\u30df\u30bf\u306f<code>\\n<\/code>\u306e\u307f\u3060\u3068\u601d\u3063\u3066\u3044\u307e\u3057\u305f )<\/p>\n<p>\u3064\u307e\u308a\u3001<\/p>\n<pre><code>$ data-test-urls-2019-5-26\nhttps:\/\/yuis-programming.com  \u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\nhttps:\/\/fumiya.org  \u30d6\u30ed\u30b0\n$\n<\/code><\/pre>\n<p>\u3068\u3044\u3046\u30b3\u30de\u30f3\u30c9\u3068\u51fa\u529b\u7d50\u679c\u304c\u3042\u308b\u3068\u3057\u3066\u3001<code>for in<\/code>\u3092\u3053\u306e\u30b3\u30de\u30f3\u30c9\u306e\u51fa\u529b\u7d50\u679c\u306b\u5bfe\u3057\u3066\u3084\u308b\u3068\u3057\u307e\u3059\u3068\u3001<\/p>\n<pre><code>$ for i in $( data-test-urls-2019-5-26 ) ; do echo $i ; done\nhttps:\/\/yuis-programming.com\n\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\nhttps:\/\/fumiya.org\n\u30d6\u30ed\u30b0\n<\/code><\/pre>\n<p>\u3053\u3046\u306a\u308a\u307e\u3059\u3002\u3053\u308c\u306f\u6539\u884c\u3060\u3051\u3067\u306a\u304f\u3001\u7a7a\u767d\u30b9\u30da\u30fc\u30b9\u3082\u30c7\u30ea\u30df\u30bf\u306b\u542b\u307e\u308c\u3066\u3044\u308b\u3053\u3068\u306e\u8a3c\u660e\u3067\u3059\u306d\u3002<\/p>\n<p>\u3053\u306e\u51fa\u529b\u3092<\/p>\n<pre><code>$ for i in $( data-test-urls-2019-5-26 ) ; do echo $i ; done\nhttps:\/\/yuis-programming.com  \u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\nhttps:\/\/fumiya.org  \u30d6\u30ed\u30b0\n<\/code><\/pre>\n<p>\u3053\u3046\u3057\u305f\u3044\u3001\u3064\u307e\u308a\u30c7\u30ea\u30df\u30bf\u3092<code>\\n<\/code>\u3060\u3051\u306b\u3057\u305f\u3044\u3068\u3044\u3046\u5834\u5408\u3001<\/p>\n<pre><code>$ IFS=\n\\n'<\/code><\/pre>\n<p>\u3053\u3046\u3057\u307e\u3059\u3002<br \/>\n<code>IFS<\/code>\u5909\u6570\u306f\u51fa\u529b\u3092\u3057\u3088\u3046\u3068\u3057\u3066\u3082\u4f55\u3082\u51fa\u529b\u3055\u308c\u306a\u3044\u306e\u3067\u3001\u9055\u3044\u304c\u308f\u304b\u308a\u306b\u304f\u3044\u3067\u3059\u304c\u3001\u5b9f\u969b\u306f\u8a66\u3057\u3066\u307f\u308c\u3070\u53cd\u6620\u3055\u308c\u3066\u3044\u308b\u306f\u305a\u3067\u3059\u3002<\/p>\n<pre><code>$ echo $IFS<\/code><\/pre>\n<p>(\u4f55\u3082\u51fa\u529b\u3055\u308c\u306a\u3044)<\/p>\n<p><code>IFS<\/code>\u306f\u666e\u901a\u306e\u5909\u6570\u306a\u306e\u3067\u3001\u4e00\u6642\u7684\u306bIFS\u3092\u5909\u66f4\u3057\u305f\u3044\u3068\u3044\u3046\u5834\u5408\u306f\u4e88\u3081<code>$ tmpIFS=$IFS<\/code>\u3092\u3057\u3066\u3001\u51e6\u7406\u304c\u7d42\u308f\u3063\u305f\u3089<code>$ IFS=$tmpIFS<\/code>\u3067\u623b\u3059\u3068\u3044\u3046\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<p><a href=\"https:\/\/askubuntu.com\/questions\/344407\/how-to-read-complete-line-in-for-loop-with-spaces\">bash &#8211; How to read complete line in &#8216;for&#8217; loop with spaces &#8211; Ask Ubuntu<\/a><br \/>\n<a href=\"https:\/\/unix.stackexchange.com\/questions\/16192\/what-is-the-ifs\">bash &#8211; What is the &#8216;IFS&#8217;? &#8211; Unix &amp; Linux Stack Exchange<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Linux\u30d1\u30bd\u30b3\u30f3\u30fb\u30b5\u30fc\u30d0\u30fc\u306e\u30b3\u30de\u30f3\u30c9\u30e9\u30a4\u30f3\u8a00\u8a9e\u3001Bash\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u8a00\u8a9e\u306eIFS(Internal Fie [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"spay_email":"","jetpack_publicize_message":"","jetpack_is_tweetstorm":false},"categories":[1],"tags":[],"acf":[],"jetpack_featured_media_url":"","jetpack_publicize_connections":[],"jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p8Rxwo-tG","_links":{"self":[{"href":"https:\/\/yuis-programming.com\/index.php?rest_route=\/wp\/v2\/posts\/1840"}],"collection":[{"href":"https:\/\/yuis-programming.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/yuis-programming.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/yuis-programming.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/yuis-programming.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1840"}],"version-history":[{"count":5,"href":"https:\/\/yuis-programming.com\/index.php?rest_route=\/wp\/v2\/posts\/1840\/revisions"}],"predecessor-version":[{"id":2637,"href":"https:\/\/yuis-programming.com\/index.php?rest_route=\/wp\/v2\/posts\/1840\/revisions\/2637"}],"wp:attachment":[{"href":"https:\/\/yuis-programming.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1840"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/yuis-programming.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1840"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/yuis-programming.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1840"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}