{"id":2036,"date":"2020-02-05T20:50:28","date_gmt":"2020-02-05T11:50:28","guid":{"rendered":"https:\/\/yuis-programming.com\/?p=2036"},"modified":"2021-07-18T11:40:42","modified_gmt":"2021-07-18T02:40:42","slug":"%e4%b8%80%e8%a6%8b%e9%81%95%e3%81%84%e3%81%8c%e3%81%aa%e3%81%95%e3%81%9d%e3%81%86%e3%81%aabash%e3%81%ae%e5%a4%89%e6%95%b0%e3%81%ab%e9%9a%a0%e3%82%8c%e3%81%9f%e6%96%87%e5%ad%97%e3%82%b3%e3%83%bc","status":"publish","type":"post","link":"https:\/\/yuis-programming.com\/?p=2036","title":{"rendered":"\u4e00\u898b\u9055\u3044\u304c\u306a\u3055\u305d\u3046\u306aBash\u306e\u5909\u6570\u306b\u96a0\u308c\u305f\u6587\u5b57\u30b3\u30fc\u30c9\u3092\u53ef\u8996\u5316\u3059\u308b&#8221;cat -A&#8221;"},"content":{"rendered":"<p>Linux\u30d1\u30bd\u30b3\u30f3\u30fb\u30b5\u30fc\u30d0\u30fc\u306eBash\u8a00\u8a9e\u306e\u30b3\u30de\u30f3\u30c9\u30e9\u30a4\u30f3\u4e0a\u3067\u4f7f\u7528\u3067\u304d\u308b&#8221;cat -A&#8221;\u30b3\u30de\u30f3\u30c9\u3067\u3001\u5909\u6570\u3084\u30d5\u30a1\u30a4\u30eb\u306b\u96a0\u308c\u305f\u6587\u5b57\u30b3\u30fc\u30c9\u3084\u6587\u5b57\u3092\u53ef\u8996\u5316\u3001\u898b\u3048\u308b\u3088\u3046\u306b\u3059\u308b\u65b9\u6cd5\u306b\u3064\u3044\u3066\u3067\u3059\u3002<\/p>\n<p>\u4e00\u898b\u30012\u3064\u306e\u5909\u6570\u306f\u540c\u4e00\u306b\u898b\u3048\u308b\u3051\u3069\u3001<code>if<\/code>\u3067\u5224\u5b9a\u3057\u3066\u307f\u308b\u3068\u306a\u305c\u304b\u3046\u307e\u304f\u3044\u304b\u306a\u3044\u3001\u3068\u3044\u3046\u3053\u3068\u304c\u3042\u308a\u307e\u3059\u3002<br \/>\n\u4f8b\u3048\u3070\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u5834\u5408\u3067\u3059\u3002<\/p>\n<p>2\u3064\u306e\u5909\u6570\u3092<code>echo<\/code>\u3057\u3066\u307f\u308b\u3068\u3001\u3053\u306e\u3088\u3046\u306b\u540c\u4e00\u306b\u898b\u3048\u307e\u3059\u3002<\/p>\n<pre><code>$ echo $md5_remote\n8a32e4c5528d684ffc9c76899e4ec256\n$ echo $md5_local\n8a32e4c5528d684ffc9c76899e4ec256\n<\/code><\/pre>\n<p><img src=\"https:\/\/yuis.xsrv.jp\/images\/ss\/ShareX_ScreenShot_cf7bbaee-0950-4e7d-9111-ee9b60ab9631.png\" alt=\"https:\/\/yuis.xsrv.jp\/images\/ss\/ShareX_ScreenShot_cf7bbaee-0950-4e7d-9111-ee9b60ab9631.png\"><\/p>\n<p>\u3053\u3061\u3089\u306e\u307b\u3046\u304c\u6b63\u78ba\u306a\u51fa\u529b\u304c\u5f97\u3089\u308c\u308b\u66f8\u304d\u65b9\u3067\u3059\u306e\u3067\u3001\u3053\u308c\u3082\u8a66\u3057\u3066\u307f\u307e\u3059\u3002\u3057\u304b\u3057\u51fa\u529b\u306f\u540c\u3058\u3067\u3059\u3002<\/p>\n<pre><code>$ echo \"${md5_remote}\"\n8a32e4c5528d684ffc9c76899e4ec256\n$ echo \"${md5_local}\"\n8a32e4c5528d684ffc9c76899e4ec256\n\n<\/code><\/pre>\n<p><img src=\"https:\/\/yuis.xsrv.jp\/images\/ss\/ShareX_ScreenShot_c4912fe0-e192-4c01-8f63-4da7dfbf7d95.png\" alt=\"https:\/\/yuis.xsrv.jp\/images\/ss\/ShareX_ScreenShot_c4912fe0-e192-4c01-8f63-4da7dfbf7d95.png\"><\/p>\n<p><code>if<\/code>\u3067\u30a4\u30b3\u30fc\u30eb\u5224\u5b9a\u3092\u3057\u3066\u307f\u3066\u3082\u3001\u3084\u306f\u308a\u30a4\u30b3\u30fc\u30eb\u3067\u306f\u306a\u3044\u3068\u8a00\u308f\u308c\u3066\u3057\u307e\u3044\u307e\u3059\u3002<\/p>\n<pre><code>if [[ \"${md5_local}\" == \"${md5_remote}\" ]]; \nthen \n  echo y \nfi \n<\/code><\/pre>\n<p><img src=\"https:\/\/yuis.xsrv.jp\/images\/ss\/ShareX_ScreenShot_625c58ca-57da-47b7-b205-3e8abfaa345f.png\" alt=\"https:\/\/yuis.xsrv.jp\/images\/ss\/ShareX_ScreenShot_625c58ca-57da-47b7-b205-3e8abfaa345f.png\"><\/p>\n<p>\u3053\u3093\u306a\u3068\u304d\u3001<code>cat -A<\/code>\u3067\u30d5\u30a1\u30a4\u30eb\u306e\u96a0\u308c\u305f\u6587\u5b57\u30b3\u30fc\u30c9\u3092\u51fa\u529b\u3059\u308b\u306e\u304c\u4fbf\u5229\u306a\u89e3\u6c7a\u7b56\u3067\u3059\u3002<\/p>\n<pre><code>$ echo \"${md5_remote}\" | cat -A\n8a32e4c5528d684ffc9c76899e4ec256^M$\n$ echo \"${md5_local}\" | cat -A\n8a32e4c5528d684ffc9c76899e4ec256$\n<\/code><\/pre>\n<p><img src=\"https:\/\/yuis.xsrv.jp\/images\/ss\/ShareX_ScreenShot_b94617d3-6304-47b3-819e-3078a9193235.png\" alt=\"https:\/\/yuis.xsrv.jp\/images\/ss\/ShareX_ScreenShot_b94617d3-6304-47b3-819e-3078a9193235.png\"><\/p>\n<p>\u3053\u306e\u3088\u3046\u306b\u3001\u4e00\u898b\u540c\u4e00\u306b\u898b\u3089\u308c\u305f2\u3064\u306e\u5909\u6570\u306f\u3001\u5b9f\u969b\u306f\u540c\u4e00\u3067\u306f\u306a\u304b\u3063\u305f\u3053\u3068\u304c\u308f\u304b\u308a\u307e\u3059\u3002<\/p>\n<p>\u3067\u306f\u3001\u5909\u6570\u3092\u540c\u4e00\u306e\u3082\u306e\u3068\u3057\u3066<code>if<\/code>\u5224\u5b9a\u3059\u308b\u306b\u306f\u3069\u3046\u3057\u305f\u3089\u3088\u3044\u306e\u3067\u3057\u3087\u3046\u304b\u3002\u4ee5\u4e0b\u95a2\u6570\u3092\u4f7f\u3063\u3066\u3001\u6587\u5b57\u5217\u306e\u6700\u521d\u3068\u6700\u5f8c\u306e\u7a7a\u767d\u3092\u53d6\u308a\u9664\u3044\u3066\u307f\u307e\u3057\u3087\u3046\u3002PHP\u306e<code>trim<\/code>\u3068\u540c\u69d8\u306e\u50cd\u304d\u3092\u3057\u307e\u3059\u3002<\/p>\n<pre><code>trim () \n{ \n    local var=\"$*\";\n    var=\"${var#\"${var%%[![:space:]]*}\"}\";\n    var=\"${var%\"${var##*[![:space:]]}\"}\";\n    echo -n \"$var\"\n}\n<\/code><\/pre>\n<p>\u3053\u3053\u3067<code>trim<\/code>\u3092\u4f7f\u3063\u3066<code>if<\/code>\u306e\u30a4\u30b3\u30fc\u30eb\u5224\u5b9a\u3092\u3057\u3066\u307f\u307e\u3059\u3002<\/p>\n<pre><code>\nif [[ \"$( trim \"${md5_local}\" )\" == \"$( trim \"${md5_remote}\" )\" ]]; \nthen \n  echo y \nfi \n\ny \n<\/code><\/pre>\n<p><img src=\"https:\/\/yuis.xsrv.jp\/images\/ss\/ShareX_ScreenShot_084e781f-b052-41a8-985d-04cc9073662e.png\" alt=\"https:\/\/yuis.xsrv.jp\/images\/ss\/ShareX_ScreenShot_084e781f-b052-41a8-985d-04cc9073662e.png\"><\/p>\n<p>\u60f3\u5b9a\u901a\u308a\u306e\u7d50\u679c\u304c\u5f97\u3089\u308c\u307e\u3057\u305f\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Linux\u30d1\u30bd\u30b3\u30f3\u30fb\u30b5\u30fc\u30d0\u30fc\u306eBash\u8a00\u8a9e\u306e\u30b3\u30de\u30f3\u30c9\u30e9\u30a4\u30f3\u4e0a\u3067\u4f7f\u7528\u3067\u304d\u308b&#8221;cat -A&#038;#8221 [&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-wQ","_links":{"self":[{"href":"https:\/\/yuis-programming.com\/index.php?rest_route=\/wp\/v2\/posts\/2036"}],"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=2036"}],"version-history":[{"count":2,"href":"https:\/\/yuis-programming.com\/index.php?rest_route=\/wp\/v2\/posts\/2036\/revisions"}],"predecessor-version":[{"id":2452,"href":"https:\/\/yuis-programming.com\/index.php?rest_route=\/wp\/v2\/posts\/2036\/revisions\/2452"}],"wp:attachment":[{"href":"https:\/\/yuis-programming.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2036"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/yuis-programming.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2036"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/yuis-programming.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2036"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}