{"id":422,"date":"2016-07-20T07:30:12","date_gmt":"2016-07-19T22:30:12","guid":{"rendered":"https:\/\/www.agent-grow.com\/self20percent\/?p=422"},"modified":"2016-11-29T14:24:13","modified_gmt":"2016-11-29T05:24:13","slug":"if-you-use-a-bash-you-should-know-that-how-to-create-menu","status":"publish","type":"post","link":"https:\/\/www.agent-grow.com\/self20percent\/2016\/07\/20\/if-you-use-a-bash-you-should-know-that-how-to-create-menu\/","title":{"rendered":"sh\/bash\u4f7f\u3044\u306a\u3089\u62bc\u3055\u3048\u3066\u304a\u304d\u305f\u3044\u7c21\u5358\u30e1\u30cb\u30e5\u30fc\u4f5c\u6210\u6cd5\uff01"},"content":{"rendered":"<h1>\u4eca\u56de\u306f\u5c0f\u30cd\u30bf\uff01<\/h1>\n<p>\u7686\u3055\u3093\u306fUnix\/Linux\/Unix\/*BSD<span class=\"footnote_referrer\"><a role=\"button\" tabindex=\"0\" onclick=\"footnote_moveToReference_422_1('footnote_plugin_reference_422_1_1');\" onkeypress=\"footnote_moveToReference_422_1('footnote_plugin_reference_422_1_1');\" ><sup id=\"footnote_plugin_tooltip_422_1_1\" class=\"footnote_plugin_tooltip_text\">1)<\/sup><\/a><span id=\"footnote_plugin_tooltip_text_422_1_1\" class=\"footnote_tooltip\">\u9806\u4e0d\u540c\u3001\u4ed6\u306b\u3082\u306a\u3093\u304b\u3042\u308b\u304b\u3082\u3067\u3059\u304c\u5272\u611b<\/span><\/span><script type=\"text\/javascript\"> jQuery('#footnote_plugin_tooltip_422_1_1').tooltip({ tip: '#footnote_plugin_tooltip_text_422_1_1', tipClass: 'footnote_tooltip', effect: 'fade', predelay: 0, fadeInSpeed: 200, delay: 400, fadeOutSpeed: 200, position: 'top center', relative: true, offset: [10, 10], });<\/script>\u3067\u4f55\u306e\u30b7\u30a7\u30eb\u3092\u4f7f\u3063\u3066\u307e\u3059\u304b\uff1f<\/p>\n<p>\u79c1\u306fsh\/bash\u3092\u3088\u304f\u4f7f\u3063\u3066\u307e\u3059\u3002\u3069\u306e\u74b0\u5883\u306b\u3082\u30c7\u30d5\u30a9\u30eb\u30c8\u3067\u5165\u3063\u3066\u3044\u308b\u3053\u3068\u304c\u671f\u5f85\u3067\u304d\u308b\u306e\u3067(\u3003\u30fb\u03c9\u30fb\u3003)<\/p>\n<p>sh\/bash\u3067\u7c21\u5358\u306a\u30e1\u30cb\u30e5\u30fc\u3092\u4f5c\u308a\u305f\u3044\u3063\u3066\u3053\u3068\u3042\u308b\u3058\u3083\u306a\u3044\u3067\u3059\u304b\u3002\u30a4\u30f3\u30bf\u30e9\u30af\u30c6\u30a3\u30d6\u306a\u3084\u3064\u3002<\/p>\n<p>\u5b9f\u306f\u7c21\u5358\u306b\u5b9f\u88c5\u3067\u304d\u308b\u3093\u3060\u3088\u301c\u3063\u3066\u3053\u3068\u3092\u899a\u3048\u3066\u304a\u304f\u3068\u3001\u3044\u308d\u3044\u308d\u6357\u308b\u3093\u3067\u3059\u3088\u306d\u2026\u2026\u3063\u3066\u304a\u8a71\u3067\u3059\u3002<\/p>\n<h1>\u307e\u305a\u306f\u30b3\u30fc\u30c9\u3092\u3054\u89a7\u304f\u3060\u3055\u3044<\/h1>\n<p>\u307e\u3042\u3001\u3053\u3093\u306a\u611f\u3058\u306e\u30b3\u30fc\u30c9\u3092\u66f8\u3051\u3070\u4f5c\u308c\u308b\u3093\u3067\u3059\u3088\u306d\u3002\u3048\u3048\u3002<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n#!\/bin\/sh\r\n\r\n# Set prompt\r\nPS3=&quot;Choose number &gt; &quot;\r\n\r\n# Set Menu items as array\r\nmenu=&quot;foo bar baz qux&quot;\r\n\r\n# Display guide message\r\necho &quot;&lt;&lt;&lt;Choose a number! or Enter 'q' for exit!&gt;&gt;&gt;&quot;\r\n\r\n# Read your choise(Set choosen number in $item, enter text in $REPLY)\r\nselect item in $menu\r\ndo\r\n    # If enter 'q', exit this shell.\r\n    if &#x5B; &quot;${REPLY}&quot; = &quot;q&quot; ]; then\r\n        echo &quot;Bye! ;-)&quot;\r\n        exit 0\r\n    fi\r\n\r\n    # Do something based on your choose.\r\n    case &quot;$item&quot; in\r\n        &quot;foo&quot; )\r\n           echo &quot;You chose FOO!&quot;;;\r\n        &quot;bar&quot; )\r\n           echo &quot;You chose BAR!&quot;;;\r\n        &quot;baz&quot; )\r\n           echo &quot;You chose BAZ!&quot;;;\r\n        &quot;qux&quot; )\r\n           echo &quot;You chose QUX!&quot;;;\r\n        * )\r\n           echo &quot;You chose wrong number ($REPLY)&quot;\r\n    esac\r\ndone\r\n<\/pre>\n<p>\u3067\u306f\u3067\u306f\u3001\u304b\u308b\u30fc\u3045\u304f\u30b3\u30fc\u30c9\u306e\u89e3\u8aac\u3092\u3070\u3002<\/p>\n<h2>4\u884c\u76ee\u2606<\/h2>\n<p>\u3053\u3053\u3067\u306f\u30d7\u30ed\u30f3\u30d7\u30c8\u5909\u6570\u3067\u3042\u308b\u300cPS3\u300d\u3092\u30ab\u30b9\u30bf\u30de\u30a4\u30ba\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>select\u3092\u4f7f\u3063\u305f\u3068\u304d\u306b\u8868\u793a\u3055\u308c\u308b\u30d7\u30ed\u30f3\u30d7\u30c8\u3067\u3059\u306d\u3002<\/p>\n<h2>7\u884c\u76ee\u2606<\/h2>\n<p>\u3053\u3053\u3067\u306f\u30e1\u30cb\u30e5\u30fc\u9805\u76ee\u306b\u8868\u793a\u3057\u305f\u3044\u30c6\u30ad\u30b9\u30c8\u30e9\u30d9\u30eb\u3092\u914d\u5217\u3067\u30bb\u30c3\u30c8\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<h2>10\u884c\u76ee\u2606<\/h2>\n<p>\u3053\u3053\u3067\u306f\u5358\u7d14\u306b\u30ac\u30a4\u30c9\u30e1\u30c3\u30bb\u30fc\u30b8\u3092\u8868\u793a\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<h2>12\u301c37\u884c\u76ee\u2606<\/h2>\n<p>\u3053\u3053\u304c\u30e1\u30a4\u30f3\u90e8\u5206\u3067\u3059\u3002\u7d30\u304b\u304f\u898b\u3066\u3044\u304d\u307e\u3057\u3087\u3046\u3002<\/p>\n<h3>13\u884c\u76ee\u2020<\/h3>\n<p>select\u3092\u4f7f\u3063\u3066\u30e1\u30cb\u30e5\u30fc\u306e\u8868\u793a\u3068\u5165\u529b\u5185\u5bb9\u306e\u53d6\u5f97\u3092\u304a\u3053\u306a\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u30e1\u30cb\u30e5\u30fc\u306b\u8868\u793a\u3055\u308c\u308b\u5185\u5bb9\u306f7\u884c\u76ee\u3067\u30bb\u30c3\u30c8\u3055\u308c\u305f\u30a2\u30ec\u3067\u3059\u306d\u3002<\/p>\n<p>\u5165\u529b\u5185\u5bb9\u306b\u3064\u3044\u3066\u3001\u5165\u529b\u306b\u5bfe\u5fdc\u3057\u305f\u30e1\u30cb\u30e5\u30fc\u306e\u30c6\u30ad\u30b9\u30c8\u30e9\u30d9\u30eb\u304c<code>$item<\/code>\u306b\u3001\u5165\u529b\u3055\u308c\u305f\u6587\u5b57\u305d\u306e\u3082\u306e\u304c<code>$REPLY<\/code>\u306b\u683c\u7d0d\u3055\u308c\u307e\u3059\u3002<\/p>\n<h3>16\u301c19\u884c\u76ee\u2020<\/h3>\n<p>\u3053\u3053\u3067\u306f\u300cq\u300d\u304c\u5165\u529b\u3055\u308c\u305f\u3068\u304d\u306b\u7d42\u4e86\u3059\u308b\u51e6\u7406\u3092\u304a\u3053\u306a\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n<h3>22\u301c33\u884c\u76ee\u2020<\/h3>\n<p>\u9078\u629e\u3055\u308c\u305f\u5185\u5bb9\u306b\u5fdc\u3058\u3066\u500b\u5225\u306e\u51e6\u7406\u3092\u304a\u3053\u306a\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u30e1\u30cb\u30e5\u30fc\u306b\u306a\u3044\u3082\u306e\u304c\u9078\u629e\u3055\u308c\u305f\u3089\u3001\u30a8\u30e9\u30fc\u30e1\u30c3\u30bb\u30fc\u30b8\u3092\u8868\u793a\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<h1>\u5b9f\u884c\u4f8b\u306f\u3053\u3093\u306a\u611f\u3058\uff01<\/h1>\n<p>\u3053\u3093\u306a\u611f\u3058\u306e\u30b3\u30fc\u30c9\u3092\u66f8\u304f\u3068\u3001\u3053\u3093\u306a\u611f\u3058\u3067\u30e1\u30cb\u30e5\u30fc\u3092\u5b9f\u73fe\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n$ sh .\/menu.sh\r\n&lt;&lt;&lt;Choose a number! or Enter 'q' for exit!&gt;&gt;&gt;\r\n1) foo\r\n2) bar\r\n3) baz\r\n4) qux\r\nChoose number &gt; 1\r\nYou chose FOO!\r\nChoose number &gt; 2\r\nYou chose BAR!\r\nChoose number &gt; 3\r\nYou chose BAZ!\r\nChoose number &gt; 4\r\nYou chose QUX!\r\nChoose number &gt; 5\r\nYou chose wrong number (5)\r\nChoose number &gt; q\r\nBye! ;-)\r\n<\/pre>\n<p>\u4fbf\u5229\u3060\u306d\u2606<\/p>\n<div class=\"speaker-mute footnotes_reference_container\"> <div class=\"footnote_container_prepare\"><p><span role=\"button\" tabindex=\"0\" class=\"footnote_reference_container_label pointer\" onclick=\"footnote_expand_collapse_reference_container_422_1();\">\u6ce8\u8a33\u306f\u3053\u3061\u3089<\/span><span role=\"button\" tabindex=\"0\" class=\"footnote_reference_container_collapse_button\" style=\"display: none;\" onclick=\"footnote_expand_collapse_reference_container_422_1();\">[<a id=\"footnote_reference_container_collapse_button_422_1\">+<\/a>]<\/span><\/p><\/div> <div id=\"footnote_references_container_422_1\" style=\"\"><table class=\"footnotes_table footnote-reference-container\"><caption class=\"accessibility\">\u6ce8\u8a33\u306f\u3053\u3061\u3089<\/caption> <tbody> \r\n\r\n<tr class=\"footnotes_plugin_reference_row\"> <th scope=\"row\" class=\"footnote_plugin_index_combi pointer\"  onclick=\"footnote_moveToAnchor_422_1('footnote_plugin_tooltip_422_1_1');\"><a id=\"footnote_plugin_reference_422_1_1\" class=\"footnote_backlink\"><span class=\"footnote_index_arrow\">&#8593;<\/span>1<\/a><\/th> <td class=\"footnote_plugin_text\">\u9806\u4e0d\u540c\u3001\u4ed6\u306b\u3082\u306a\u3093\u304b\u3042\u308b\u304b\u3082\u3067\u3059\u304c\u5272\u611b<\/td><\/tr>\r\n\r\n <\/tbody> <\/table> <\/div><\/div><script type=\"text\/javascript\"> function footnote_expand_reference_container_422_1() { jQuery('#footnote_references_container_422_1').show(); jQuery('#footnote_reference_container_collapse_button_422_1').text('\u2212'); } function footnote_collapse_reference_container_422_1() { jQuery('#footnote_references_container_422_1').hide(); jQuery('#footnote_reference_container_collapse_button_422_1').text('+'); } function footnote_expand_collapse_reference_container_422_1() { if (jQuery('#footnote_references_container_422_1').is(':hidden')) { footnote_expand_reference_container_422_1(); } else { footnote_collapse_reference_container_422_1(); } } function footnote_moveToReference_422_1(p_str_TargetID) { footnote_expand_reference_container_422_1(); var l_obj_Target = jQuery('#' + p_str_TargetID); if (l_obj_Target.length) { jQuery( 'html, body' ).delay( 0 ); jQuery('html, body').animate({ scrollTop: l_obj_Target.offset().top - window.innerHeight * 0.2 }, 380); } } function footnote_moveToAnchor_422_1(p_str_TargetID) { footnote_expand_reference_container_422_1(); var l_obj_Target = jQuery('#' + p_str_TargetID); if (l_obj_Target.length) { jQuery( 'html, body' ).delay( 0 ); jQuery('html, body').animate({ scrollTop: l_obj_Target.offset().top - window.innerHeight * 0.2 }, 380); } }<\/script>","protected":false},"excerpt":{"rendered":"<p>\u4eca\u56de\u306f\u5c0f\u30cd\u30bf\uff01 \u7686\u3055\u3093\u306fUnix\/Linux\/Unix\/*BSD1)\u9806\u4e0d\u540c\u3001\u4ed6\u306b\u3082\u306a\u3093\u304b\u3042\u308b\u304b\u3082\u3067\u3059\u304c\u5272\u611b\u3067\u4f55\u306e\u30b7\u30a7\u30eb\u3092\u4f7f\u3063\u3066\u307e\u3059\u304b\uff1f \u79c1\u306fsh\/bash\u3092\u3088\u304f\u4f7f\u3063\u3066\u307e\u3059\u3002\u3069\u306e\u74b0\u5883\u306b\u3082\u30c7\u30d5\u30a9\u30eb\u30c8\u3067\u5165\u3063\u3066\u3044\u308b\u3053\u3068\u304c\u671f\u5f85\u3067\u304d [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":1145,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":true,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[10],"tags":[47,50,48,49],"class_list":["post-422","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tech","tag-bash","tag-50","tag-48","tag-49"],"jetpack_featured_media_url":"https:\/\/www.agent-grow.com\/self20percent\/wp-content\/uploads\/2016\/07\/161101-0001.jpg","jetpack_shortlink":"https:\/\/wp.me\/p7Bq4F-6O","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.agent-grow.com\/self20percent\/wp-json\/wp\/v2\/posts\/422","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.agent-grow.com\/self20percent\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.agent-grow.com\/self20percent\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.agent-grow.com\/self20percent\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.agent-grow.com\/self20percent\/wp-json\/wp\/v2\/comments?post=422"}],"version-history":[{"count":0,"href":"https:\/\/www.agent-grow.com\/self20percent\/wp-json\/wp\/v2\/posts\/422\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.agent-grow.com\/self20percent\/wp-json\/wp\/v2\/media\/1145"}],"wp:attachment":[{"href":"https:\/\/www.agent-grow.com\/self20percent\/wp-json\/wp\/v2\/media?parent=422"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.agent-grow.com\/self20percent\/wp-json\/wp\/v2\/categories?post=422"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.agent-grow.com\/self20percent\/wp-json\/wp\/v2\/tags?post=422"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}