{"id":13488,"date":"2023-08-05T09:11:05","date_gmt":"2023-08-05T00:11:05","guid":{"rendered":"https:\/\/lab4ict.com\/system\/?p=13488"},"modified":"2023-08-05T09:30:55","modified_gmt":"2023-08-05T00:30:55","slug":"bash%e3%82%92%e4%bd%bf%e7%94%a8%e3%81%97%e3%81%a6%e3%82%b9%e3%82%af%e3%83%aa%e3%83%97%e3%83%88%e3%82%92%e4%bd%9c%e6%88%90%e3%81%99%e3%82%8b%ef%bc%81%ef%bc%88%e9%96%a2%e6%95%b0%ef%bc%89","status":"publish","type":"post","link":"https:\/\/lab4ict.com\/system\/archives\/13488","title":{"rendered":"Bash\u3092\u4f7f\u7528\u3057\u3066\u30b9\u30af\u30ea\u30d7\u30c8\u3092\u4f5c\u6210\u3059\u308b\uff01\uff08\u95a2\u6570\uff09"},"content":{"rendered":"<p>Bash\u306e\u30b9\u30af\u30ea\u30d7\u30c8\u3067\u3001\u95a2\u6570\u3092\u4f7f\u7528\u3059\u308b\u65b9\u6cd5\u3067\u3059\u3002<br \/>\n<!--more--><\/p>\n<h2>\u95a2\u6570\u306e\u66f8\u5f0f\u3092\u78ba\u8a8d\u3059\u308b\uff01<\/h2>\n<p>for\u6587\u306e\u66f8\u5f0f\u306f\u3001\u4ee5\u4e0b\u306b\u306a\u308a\u307e\u3059\u3002\u95a2\u6570\u3092\u5b9a\u7fa9\u3057\u3066\u3001\u95a2\u6570\u540d\u3092\u8a18\u8f09\u3057\u3066\u95a2\u6570\u3092\u547c\u3073\u51fa\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\nfunction \u95a2\u6570\u540d() {\r\n    #\r\n}\r\n\r\n\u95a2\u6570\u540d\r\n<\/pre>\n<p>\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u3057\u3066\u3001\u5f15\u6570\u3092\u6307\u5b9a\u3057\u3066\u547c\u3073\u51fa\u3059\u3053\u3068\u3082\u53ef\u80fd\u3067\u3059\u3002<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\n\u95a2\u6570\u540d \u5f15\u65701 \u5f15\u65702 \u30fb\u30fb\u30fb\r\n<\/pre>\n<h2>\u30b5\u30f3\u30d7\u30eb\u306e\u30b9\u30af\u30ea\u30d7\u30c8\u3092\u4f5c\u6210\u3059\u308b\uff01<\/h2>\n<p>\u4e3b\u51e6\u7406\u3001\u5f15\u6570\u306e\u30c1\u30a7\u30c3\u30af\u3001\u30ed\u30b0\u51fa\u529b\u3092\u95a2\u6570\u5316\u3057\u3066\u307f\u307e\u3059\u3002\u4ee5\u4e0b\u3001\u30b5\u30f3\u30d7\u30eb\u306e\u30b9\u30af\u30ea\u30d7\u30c8\u3067\u3059\u3002<\/p>\n<pre class=\"brush: plain; highlight: [1,14,17,19,26,28,35,38,41,44,47]; title: ; notranslate\" title=\"\">\r\n$ cat .\/sample_bash_07.sh \r\n#!\/bin\/bash\r\n#\r\n# Usage   : sample_bash_07.sh $1\r\n# Version : 1.0\r\n#\r\nSHELL_NAME=`basename $0`\r\nSTA_MSG=Start!\r\nEND_MSG=End!\r\nRET_CD=0\r\nLOG_MSG=&quot;Message!&quot;\r\n\r\n# Functions\r\nfunction write_log() {\r\n    echo &quot;${SHELL_NAME} : $@&quot;\r\n    \/usr\/bin\/logger -ip local0.crit -t ${SHELL_NAME} $@ \r\n}\r\n\r\nfunction check_arg_num() {\r\n    if &#x5B;&#x5B; $1 -ge 2 ]]; then\r\n        LOG_MSG=&quot;Too many Arguments : $1&quot;\r\n        write_log &quot;${LOG_MSG}&quot;\r\n        write_log &quot;${END_MSG}&quot;\r\n        exit 9\r\n    fi\r\n}\r\n\r\nfunction main() {\r\n    if &#x5B;&#x5B; -z &quot;$1&quot; ]]; then\r\n        LOG_MSG=&quot;Default Message!&quot;\r\n    else\r\n        LOG_MSG=&quot;$@&quot;\r\n    fi\r\n    write_log &quot;${LOG_MSG}&quot;\r\n}\r\n\r\n# Start\r\nwrite_log ${STA_MSG} \r\n    \r\n# Check\r\ncheck_arg_num $#\r\n\r\n# Main\r\nmain $@\r\n\r\n# End\r\nwrite_log &quot;${END_MSG}&quot;\r\nexit ${RET_CD}\r\n\r\n# End of File\r\n\r\n<\/pre>\n<h2>\u30b5\u30f3\u30d7\u30eb\u306e\u30b9\u30af\u30ea\u30d7\u30c8\u3092\u5b9f\u884c\u3057\u3066\u307f\u308b\uff01<\/h2>\n<p>\u30b5\u30f3\u30d7\u30eb\u306e\u30b9\u30af\u30ea\u30d7\u30c8\u3092\u5b9f\u884c\u3057\u3066\u307f\u307e\u3059\u3002\u5f15\u6570\u306a\u3057\u306e\u30d1\u30bf\u30fc\u30f3\u3067\u3059\u3002<\/p>\n<pre class=\"brush: plain; highlight: [1]; title: ; notranslate\" title=\"\">\r\n$ .\/sample_bash_07.sh\r\nsample_bash_07.sh : Start!\r\nsample_bash_07.sh : Default Message!\r\nsample_bash_07.sh : End!\r\n<\/pre>\n<p>\u5f15\u65701\u500b\u306e\u30d1\u30bf\u30fc\u30f3\u3067\u3059\u3002<\/p>\n<pre class=\"brush: plain; highlight: [1]; title: ; notranslate\" title=\"\">\r\n$ .\/sample_bash_07.sh Hello\r\nsample_bash_07.sh : Start!\r\nsample_bash_07.sh : Hello\r\nsample_bash_07.sh : End!\r\n<\/pre>\n<p>\u5f15\u65702\u500b\u306e\u30d1\u30bf\u30fc\u30f3\u3067\u3059\u3002<\/p>\n<pre class=\"brush: plain; highlight: [1]; title: ; notranslate\" title=\"\">\r\n$ .\/sample_bash_07.sh Hello Everyone\r\nsample_bash_07.sh : Start!\r\nsample_bash_07.sh : Too many Arguments : 2\r\nsample_bash_07.sh : End!\r\n<\/pre>\n<h2>\u304a\u308f\u308a\u306b<\/h2>\n<p>Bash\u3067\u95a2\u6570\u3092\u4f7f\u7528\u3057\u3066\u3001\u30b7\u30a7\u30eb\u3092\u69cb\u9020\u5316\u3057\u3066\u307f\u307e\u3057\u305f\u3002<\/p>\n<h2>\u95a2\u9023\u8a18\u4e8b<\/h2>\n<div class=\"sc_getpost\"><a class=\"clearfix\" href=\"https:\/\/lab4ict.com\/system\/archives\/8692\" ><div class=\"sc_getpost_thumb post-box-thumbnail__wrap\"><img decoding=\"async\" src=\"data:image\/gif;base64,R0lGODdhAQABAPAAAN3d3QAAACwAAAAAAQABAAACAkQBADs=\" width=\"150\" height=\"150\" alt=\"\u3010\u8a18\u4e8b\u4e00\u89a7\u3011Linux\u3067\u30b7\u30a7\u30eb\u30b9\u30af\u30ea\u30d7\u30c8\u3092\u4f5c\u6210\u3059\u308b\uff01\uff08bash\uff09\" loading=\"lazy\" data-src=\"https:\/\/lab4ict.com\/system\/wp-content\/uploads\/2021\/02\/fi_linux_01-150x150.png\" class=\"lazyload\"><\/div><div class=\"title\">\u3010\u8a18\u4e8b\u4e00\u89a7\u3011Linux\u3067\u30b7\u30a7\u30eb\u30b9\u30af\u30ea\u30d7\u30c8\u3092\u4f5c\u6210\u3059\u308b\uff01\uff08bash\uff09<\/div><div class=\"substr\">Linux\u306ebash\u3067\u3001\u30b7\u30a7\u30eb\u30b9\u30af\u30ea\u30d7\u30c8\u3092\u4f5c\u6210\u3059\u308b\u305f\u3081\u306e\u8a18\u4e8b\u4e00\u89a7\u3067\u3059\u3002...<\/div><\/a><\/div>\n<h2>\u95a2\u9023\u66f8\u7c4d\uff08Amazon\uff09<\/h2>\n<p><iframe sandbox=\"allow-popups allow-scripts allow-modals allow-forms allow-same-origin\" style=\"width:120px;height:240px;\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\" frameborder=\"0\" src=\"\/\/rcm-fe.amazon-adsystem.com\/e\/cm?lt1=_blank&bc1=000000&IS2=1&bg1=FFFFFF&fc1=000000&lc1=0000FF&t=infotecr-22&language=ja_JP&o=9&p=8&l=as4&m=amazon&f=ifr&ref=as_ss_li_til&asins=4774186945&linkId=51dbc0ee6d79ef74ced87300db344bdb\"><\/iframe><\/p>\n<hr \/>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Bash\u306e\u30b9\u30af\u30ea\u30d7\u30c8\u3067\u3001\u95a2\u6570\u3092\u4f7f\u7528\u3059\u308b\u65b9\u6cd5\u3067\u3059\u3002<\/p>\n","protected":false},"author":1,"featured_media":5527,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[189],"tags":[374,863,761,680,630,855,862],"class_list":["post-13488","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-shell-script","tag-bash","tag-function","tag-761","tag-680","tag-630","tag-855","tag-862"],"_links":{"self":[{"href":"https:\/\/lab4ict.com\/system\/wp-json\/wp\/v2\/posts\/13488","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lab4ict.com\/system\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lab4ict.com\/system\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lab4ict.com\/system\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/lab4ict.com\/system\/wp-json\/wp\/v2\/comments?post=13488"}],"version-history":[{"count":11,"href":"https:\/\/lab4ict.com\/system\/wp-json\/wp\/v2\/posts\/13488\/revisions"}],"predecessor-version":[{"id":13499,"href":"https:\/\/lab4ict.com\/system\/wp-json\/wp\/v2\/posts\/13488\/revisions\/13499"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lab4ict.com\/system\/wp-json\/wp\/v2\/media\/5527"}],"wp:attachment":[{"href":"https:\/\/lab4ict.com\/system\/wp-json\/wp\/v2\/media?parent=13488"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lab4ict.com\/system\/wp-json\/wp\/v2\/categories?post=13488"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lab4ict.com\/system\/wp-json\/wp\/v2\/tags?post=13488"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}