{"id":1938,"date":"2016-02-01T05:02:24","date_gmt":"2016-01-31T21:02:24","guid":{"rendered":"http:\/\/www.gigiwangs.com\/?p=1938"},"modified":"2016-02-01T05:02:24","modified_gmt":"2016-01-31T21:02:24","slug":"shell-%e5%ad%97%e7%ac%a6%e4%b8%b2%e5%88%86%e9%9a%94%e7%84%b6%e5%90%8e","status":"publish","type":"post","link":"https:\/\/www.mujins.com\/?p=1938","title":{"rendered":"SHELL \u5b57\u7b26\u4e32\u5206\u9694\u7136\u540e.."},"content":{"rendered":"<p>\u5e9f\u8bdd\u4e0d\u8bf4\uff0c\u76f4\u63a5\u4e0a\u4ee3\u7801\uff1a<br \/>\n\u65b9\u6848\u4e00\uff1a<\/p>\n<pre class=\"brush:bash\">divStrArry () {\n    str=$@;\n    OLD_IFS=\"$IFS\"\n    IFS=\"\/\"\n    arr=($str)\n    IFS=\"$OLD_IFS\"\n    num=${#arr[@]}\n    for i in ${arr[@]}\n    do\n      echo $i\n    done \n}\n<\/pre>\n<p>\u65b9\u6848\u4e8c\uff1a<\/p>\n<pre class=\"brush:bash\">divStrArry () {\n    str=\"$@\";\n    set -A arr $(echo $str|tr '\/' ' '|tr -s ' ')\n    num=${#arr[@]}\n    for i in ${arr[@]}\n    do\n      echo \"$i\"\n    done\n}\n<\/pre>\n<p>\u90a3\u4e48\u6709\u4e00\u4e2a\u9700\u6c42\uff1a\u4f7f\u7528shell\u811a\u672cFTP \u5efa\u7acb\u591a\u7ea7\u76ee\u5f55\uff1a\u5305\u62ec\u5b50\u76ee\u5f55\u3002\u4e0d\u652f\u6301mkdir -p\u7684\u3002<br \/>\n\u540c\u6837\u76f4\u63a5\u4e0a\u4ee3\u7801<\/p>\n<pre class=\"brush:bash\">funnc() {\n    local r\n    local a\n    r=\"$@\"\n    while [[ \"$r\" != \"$a\" ]] ; do\n        a=${r%%\/*}\n        echo \"mkdir $a\"\n        echo \"cd $a\"\n        r=${r#*\/}\n    done\n}\nftp -inv 0.0.0.0 &lt; &lt; EOF\nuser username pass\nbin\n$(funnc Misc\/Sub\/acct\/${host_date})\nmput xw.TXT\nbye\nEOF\n<\/pre>\n<p>\u5176\u5b83\u5e9f\u8bdd\u4e5f\u4e0d\u8bf4\u4e86&#8230;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5e9f\u8bdd\u4e0d\u8bf4\uff0c\u76f4\u63a5\u4e0a\u4ee3\u7801\uff1a \u65b9\u6848\u4e00\uff1a divStrArry () { str=$@; OLD_IFS=&#8221;$IFS&#8221; IFS=&#8221;\/&#8221; arr=($str) IFS=&#8221;$OLD_IFS&#8221; num=${#arr[@]} for i in ${arr[@]} do echo $i done } \u65b9\u6848\u4e8c\uff1a divStrArry () { str=&#8221;$@&#8221;; set -A arr $(echo $str|tr &#8216;\/&#8217; &#8216; &#8216;|tr -s &#8216; &#8216;) num=${#arr[@]} for i in ${arr[@]} do echo &#8220;$i&#8221; done } \u90a3\u4e48\u6709\u4e00\u4e2a\u9700\u6c42\uff1a\u4f7f\u7528shell\u811a\u672cFTP \u5efa\u7acb\u591a\u7ea7\u76ee\u5f55\uff1a\u5305\u62ec\u5b50\u76ee\u5f55\u3002\u4e0d\u652f\u6301mkdir -p\u7684\u3002 \u540c\u6837\u76f4\u63a5\u4e0a\u4ee3\u7801 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":1635,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[31,21],"tags":[22,91],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/www.mujins.com\/index.php?rest_route=\/wp\/v2\/posts\/1938"}],"collection":[{"href":"https:\/\/www.mujins.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.mujins.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.mujins.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.mujins.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1938"}],"version-history":[{"count":0,"href":"https:\/\/www.mujins.com\/index.php?rest_route=\/wp\/v2\/posts\/1938\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.mujins.com\/index.php?rest_route=\/"}],"wp:attachment":[{"href":"https:\/\/www.mujins.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1938"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.mujins.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1938"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.mujins.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1938"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}