{"id":45,"date":"2013-04-24T22:51:44","date_gmt":"2013-04-24T14:51:44","guid":{"rendered":"http:\/\/coderbee.net\/?p=45"},"modified":"2013-04-24T22:51:44","modified_gmt":"2013-04-24T14:51:44","slug":"%e6%89%b9%e5%a4%84%e7%90%86%e7%ac%94%e8%ae%b0","status":"publish","type":"post","link":"https:\/\/coderbee.net\/index.php\/windows\/20130424\/45","title":{"rendered":"\u6279\u5904\u7406\u7b14\u8bb0"},"content":{"rendered":"<p>\u6279\u5904\u7406\u53ef\u4ee5\u8bf4\u662fwindows\u4e0b\u7684shell\uff0c\u867d\u7136\u6ca1\u6709shell\u5f3a\u5927\u5427\uff0c\u4f46\u4e5f\u8db3\u4ee5\u7528\u6765\u5b8c\u6210\u5f88\u591a\u4efb\u52a1\u4e86\u3002\u8fd9\u91cc\u8bb0\u5f55\u4e86\u5927\u90e8\u5206\u7684\u6279\u5904\u7406\u7528\u6cd5\uff0c\u6700\u540e\u6709\u4e00\u4e2a\u8c03\u7528yuicompressor\u538b\u7f29js\/css\u7684\u811a\u672c\u3002<br \/>\n<!--more--><\/p>\n<h2>\u57fa\u7840<\/h2>\n<p>\u5148\u8bf4\u4f7f\u7528\u6279\u5904\u7406\u8981\u6ce8\u610f\u7684\u51e0\u70b9\uff1a<\/p>\n<ol>\n<li>\u5c3d\u91cf\u4e0d\u8981\u5c06\u6279\u5904\u7406\u8981\u64cd\u4f5c\u7684\u6587\u4ef6\u653e\u5728\u4e0d\u540c\u7684\u76d8\u7b26\u4e0b\uff0c\u6240\u6709\u8981\u5904\u7406\u7684\u6587\u4ef6\u6700\u597d\u653e\u5728\u540c\u4e00\u4e2a\u76ee\u5f55\u4e0b\uff1b<\/li>\n<li>\u6587\u4ef6\/\u5939\u540d\u6700\u597d\u4e0d\u8981\u7a7a\u683c\uff0c\u56e0\u4e3a\u6279\u5904\u7406\u7684\u547d\u4ee4\u53c2\u6570\u4e00\u822c\u662f\u7528\u7a7a\u683c\u5206\u9694\u7684\uff0c\u6709\u7a7a\u683c\u7684\u8bdd\uff0c\u7528\u6587\u4ef6\u540d\u505a\u53c2\u6570\u5bb9\u6613\u51fa\u9519\uff1b<\/li>\n<li>\u5c3d\u91cf\u4f7f\u7528\u76f8\u5bf9\u8def\u5f84\uff0c\u4e0d\u8981\u7528\u7edd\u5bf9\u8def\u5f84\uff1b<\/li>\n<li>\u5bf9\u4e8e\u8981\u4f7f\u7528\u4f46\u53c8\u4e0d\u7406\u89e3\u7684\u547d\u4ee4\uff0c\u4e00\u5b9a\u8981\u5148\u67e5\u770b\u547d\u4ee4\u7684\u4f7f\u7528\u8bf4\u660e\uff1a<code>help cmdName<\/code><\/li>\n<\/ol>\n<h2>\u4e00\u4e9b\u547d\u4ee4<\/h2>\n<h3>\u7981\u6b62\u547d\u4ee4\u56de\u663e<\/h3>\n<p><code>echo off<\/code> \u8868\u793a\u6b64\u8bed\u53e5\u540e\u7684\u6240\u6709\u8fd0\u884c\u7684\u547d\u4ee4\u90fd\u4e0d\u663e\u793a\u547d\u4ee4\u672c\u8eab\u3002<\/p>\n<p><code>@<\/code> \u4e0e <code>echo off<\/code> \u76f8\u4f3c\uff0c\u4f46\u5b83\u662f\u52a0\u5728\u6bcf\u4e2a\u547d\u4ee4\u7684\u6700\u524d\u9762\uff0c\u53ea\u4f5c\u7528\u4e8e\u5f53\u524d\u547d\u4ee4\uff0c\u8868\u793a\u8fd0\u884c\u65f6\u4e0d\u663e\u793a\u8fd9\u4e00\u547d\u4ee4\u3002<\/p>\n<h3>\u6ce8\u91ca<\/h3>\n<p><code>rem<\/code> \u7528\u6765\u6ce8\u91ca\u3002<\/p>\n<h3>\u8f93\u51fa\u4fe1\u606f<\/h3>\n<p><code>echo<\/code> \u8868\u793a\u663e\u793a\u6b64\u547d\u4ee4\u540e\u7684\u5b57\u7b26\uff0c\u4e5f\u53ef\u4ee5\u7528\u4e8e\u5c06\u547d\u4ee4\u540e\u7684\u5b57\u7b26\u4e32\u8f93\u51fa\u5230\u6587\u4ef6\uff0c\u5982\u4e0b\u9762\u6240\u793a<br \/>\n<code>echo abc to file &gt;&gt; targetfile.txt<\/code><br \/>\n\u4e0a\u9762\u7684\u547d\u4ee4\u5c06\u628a<code>abc to fil<\/code>\u5199\u5230<code>targetfile.txt<\/code>\u3002<\/p>\n<h3>\u6682\u505c<\/h3>\n<p><code>pause<\/code> \u6682\u505c\u6267\u884c\u5e76\u5728\u5c4f\u5e55\u4e0a\u663e\u793a<code>Press any key to continue...<\/code>\u7684\u63d0\u793a\uff0c\u7b49\u5f85\u7528\u6237\u6309\u4efb\u610f\u952e\u540e\u7ee7\u7eed\u3002<\/p>\n<h3>\u9000\u51fa\u811a\u672c<\/h3>\n<p><code>exit \/b code<\/code> \u52a0\u4e0a<code>\/b<\/code>\u9009\u9879\u8868\u793a\u9000\u51fa\u5f53\u524d\u6279\u5904\u7406\u811a\u672c\uff0c\u800c\u4e0d\u662fcmd.exe\uff0c\u76f8\u5f53\u4e8e\u51fd\u6570\u7684<code>return<\/code>\u8bed\u53e5\u3002<code>code<\/code>\u662f\u4e2a\u6570\u5b57\uff0c\u8868\u793a\u6267\u884c\u7ed3\u679c\u3002<\/p>\n<h3>\u8c03\u7528\u5176\u4ed6\u6279\u5904\u7406<\/h3>\n<p><code>call<\/code> \u7528\u6765\u8c03\u7528\u53e6\u4e00\u4e2a\u6279\u5904\u7406\uff0c\u5c31\u50cf\u51fd\u6570\u8c03\u7528\uff08\u5982\u679c\u4e0d\u7528call\u800c\u76f4\u63a5\u8c03\u7528\u522b\u7684\u6279\u5904\u7406\u6587\u4ef6\uff0c\u90a3\u4e48\u6267\u884c\u5b8c\u6210\u90a3\u4e2a\u6279\u5904\u7406\u6587\u4ef6\u540e\u5c06\u65e0\u6cd5\u8fd4\u56de\u5f53\u524d\u6587\u4ef6\u540e\u7eed\u7684\u547d\u4ee4\uff09<\/p>\n<p>\u5728\u88ab\u8c03\u7528\u7684\u6279\u5904\u7406\u91cc\uff0c<code>%[1-9]<\/code> \u8868\u793a\u4f20\u9012\u8fdb\u6765\u7684\u53c2\u6570\uff0c\u53c2\u6570\u662f\u6307\u8c03\u7528\u8005\u5728\u6587\u4ef6\u540d\u540e\u52a0\u4ee5\u7a7a\u683c\u5206\u9694\u7684\u5b57\u7b26\u4e32\u3002<br \/>\n<code>%0<\/code> \u8868\u793a\u6279\u5904\u7406\u547d\u4ee4\u672c\u8eab\uff0c\u5176\u4ed6\u53c2\u6570\u5b57\u7b26\u4e32\u7528<code>%1<\/code>\u5230<code>%9<\/code>\u8868\u793a<\/p>\n<p>\u6279\u5904\u7406\u8c03\u7528\u793a\u4f8b\uff0c\u4e0d\u5e26\u53c2\u6570<br \/>\n<code>call for.bat firstparamvalue<\/code><\/p>\n<h3>\u8f93\u51fa\u6587\u4ef6\u5185\u5bb9<\/h3>\n<p><code>type<\/code> \u7528\u6765\u8f93\u51fa\u6587\u4ef6\u5185\u5bb9\uff0c\u4e0b\u9762\u7684\u547d\u4ee4\u8f93\u51fasubfor.bat\u6587\u4ef6\u7684\u5185\u5bb9<br \/>\n<code>type subfor.bat<\/code><\/p>\n<h3>\u5b9a\u4e49\u53d8\u91cf<\/h3>\n<p><code>set<\/code> \u7528\u4e8e\u5b9a\u4e49\u53d8\u91cf\u3002<\/p>\n<h2>for \u5faa\u73af<\/h2>\n<p>for\u5faa\u73af\u904d\u5386\u4e00\u4e2a\u96c6\u5408\u5e76\u6267\u884c\u6307\u5b9a\u547d\u4ee4\uff1a<br \/>\n<code>FOR %%variable IN (set) DO command [command-parameters]<\/code><\/p>\n<ul>\n<li><code>%%variable<\/code>           \u6307\u5b9a\u4e00\u4e2a\u5355\u4e00\u5b57\u6bcd\u53ef\u66ff\u6362\u7684\u53c2\u6570\u3002  <\/li>\n<li><code>(set)<\/code>                \u6307\u5b9a\u4e00\u4e2a\u6216\u4e00\u7ec4\u6587\u4ef6\u3002\u53ef\u4ee5\u4f7f\u7528\u901a\u914d\u7b26\u3002  <\/li>\n<li><code>command<\/code>              \u6307\u5b9a\u5bf9\u6bcf\u4e2a\u6587\u4ef6\u6267\u884c\u7684\u547d\u4ee4\u3002  <\/li>\n<li><code>command-parameters<\/code>   \u4e3a\u7279\u5b9a\u547d\u4ee4\u6307\u5b9a\u53c2\u6570\u6216\u547d\u4ee4\u884c\u5f00\u5173\u3002  <\/li>\n<\/ul>\n<h3>for \u5faa\u73af\u904d\u5386\u96c6\u5408<\/h3>\n<pre><code>\nset items=a b c d  \nset letters=x y z  \n  \nfor %%a in (%items%) do (  \n    for %%b in (%letters%) do (  \n        call subfor.bat %%a %%b  \n    )  \n)\n\nsubfor.bat\n<pre><code>\n@echo off  \necho echo in subfor.bat :  %1 %2  \n<\/code><\/pre>\n<p><\/code><\/p>\n<h3>for\u5faa\u73af\u5904\u7406\u7528\u901a\u914d\u7b26\u6307\u5b9a\u7684\u4e00\u7ec4\u6587\u4ef6<\/h3>\n<pre><code>\nfor %%a in (*.txt) do (  \n    rem \u5982\u679c\u6587\u4ef6\u540d\u6709\u7a7a\u683c\uff0c\u5fc5\u987b\u4f7f\u7528\"\"  \n    rem type \"%%a\"  \n)  \n<\/code><\/pre>\n<h3>for \u5faa\u73af\u5904\u7406\u6587\u4ef6\u5185\u5bb9<\/h3>\n<pre><code>\nrem \u8bfb\u53d6text.txt\u4e2d\u7684\u6bcf\u4e00\u884c\u4f5c\u4e3a\u53c2\u6570%%a\u7684\u503c\uff0c\u8c03\u7528\u5faa\u73af\u4f53  \nfor \/F \"delims=\" %%a in (text.txt) do (  \n    echo %%a  \n)  \n<\/code><\/pre>\n<h3>\u6570\u503c\u8303\u56f4\u8fed\u4ee3<\/h3>\n<p>\u683c\u5f0f\uff1a <code>for \/L %%i in (start, step, end) do cmd<\/code><\/p>\n<p><code>for \/L %%i in (1, 1, 5) do echo %%i<\/code><\/p>\n<p>for \u5faa\u73af\u547d\u4ee4\u7684\u4f7f\u7528\u6bd4\u8f83\u590d\u6742\uff0c\u5fc5\u987b\u8ba4\u771f\u9605\u8bfb\u4f7f\u7528\u8bf4\u660e\u3002<\/p>\n<h2>if\u8bed\u53e5<\/h2>\n<p>if\u8bed\u53e5\u6709\u4e09\u79cd\u683c\u5f0f\uff1a<\/p>\n<ol>\n<li>\u5224\u5b9a\u53c2\u6570\u662f\u5426\u7b26\u5408\u671f\u671b\u503c\uff1a<code>if [not] \"\u53c2\u6570\" == \"\u5b57\u7b26\u4e32\" \u5f85\u6267\u884c\u7684\u547d\u4ee4<\/code>\n<pre><code>\nif \"%1\" == \"abc 123\"  (  \n    echo first var'value is :abc 123  \n) else (  \n    echo first var'value not excepted, it is :%1  \n)  \n<\/code><\/pre>\n<\/li>\n<li>\u5224\u5b9a\u6587\u4ef6\u662f\u5426\u5b58\u5728\uff1a<code>if [not] exist [\u8def\u5f84\\\\\u6587\u4ef6\u540d] \u5f85\u6267\u884c\u7684\u547d\u4ee4<\/code>\n<pre><code>\nif exist \"abc 123.txt\"  (  \n    echo content of file abc 123.txt is :  \n    type \"abc 123.txt\"  \n) else (  \n    echo abc 123.txt is exist .  \n)\n\ncall subif.bat 3  \n<\/code><\/pre>\n<\/li>\n<li>\u6839\u636eerrorlevel\u6765\u6267\u884c\u547d\u4ee4\n<p><code>if errorlevel &lt;\u6570\u5b57&gt; \u5f85\u6267\u884c\u7684\u547d\u4ee4<\/code><br \/>\n\u8fd4\u56de\u503c\u5fc5\u987b\u6309\u7167\u4ece\u5927\u5230\u5c0f\u7684\u987a\u5e8f\u6392\u5217 \u3002<\/p>\n<\/li>\n<\/ol>\n<pre><code>\n    if errorlevel 3 (  \n        echo errorlevel is three .  \n    ) else if errorlevel 2 (  \n        echo errorlevel is two .  \n    ) else if errorlevel 1 (  \n        echo errorlevel is one .  \n    ) else (  \n        echo execute success .  \n    )\n    <\/code><\/pre>\n<p>subif.bat<\/p>\n<pre><code>\n@echo off\nif \"%1\" == \"\" (  \n    rem \u52a0\u4e0a\/b\u9009\u9879\u8868\u793a\u9000\u51fa\u5f53\u524d\u6279\u5904\u7406\uff0c\u800c\u4e0d\u662f\u9000\u51facmd.exe  \n    exit \/b 0  \n) else (  \n    exit \/b %1  \n)\n<\/code><\/pre>\n<h2>goto \u8bed\u53e5<\/h2>\n<p>goto\u8bed\u53e5\u53ef\u4ee5\u7ed3\u5408\u6807\u7b7e\u8fdb\u884c\u8df3\u8f6c\u3002<\/p>\n<p>\u6807\u7b7e\u5c31\u662f\u7528\u5192\u53f7\u52a0\u5355\u8bcd\u5b9a\u4e49\uff0c\u5355\u72ec\u653e\u5728\u4e00\u884c\u5982\uff1a <code>:labelName<\/code><\/p>\n<pre><code>\n@echo off  \nif \"%1\" == \"\" (  \n    goto default  \n) else if \"%1\" == \"helloworld\" (  \n    goto helloworld  \n)  \n  \n:default  \necho you come to default .  \ngoto end  \n  \n:hellowrold  \necho why you come to hello world ?  \ngoto end  \n\n:end\n<\/code><\/pre>\n<h2>\u4e00\u4e2a\u8f93\u51fa\u7cfb\u7edf\u547d\u4ee4\u5e2e\u52a9\u6587\u6863\u7684\u811a\u672c<\/h2>\n<p>createHelp.bat \u6b64\u811a\u672c\u53ef\u4ee5\u8f93\u51fa\u7cfb\u7edf\u547d\u4ee4\u7684\u5e2e\u52a9\u6587\u6863\u3002<\/p>\n<pre><code>\n@echo off\nset cmds=FIND SORT DISKPART\n\nfor \/F \"usebackq\" %%i in (`help`) do (  \n    for %%a in (%cmds%) do (  \n        if not \"%%a\" == \"%%i\" (  \n            help \"%%i\" > help\/%%i-help.txt  \n        )  \n    )  \n) \n<\/code><\/pre>\n<h2>\u4e00\u4e2a\u6587\u4ef6\u5904\u7406\u7684\u793a\u4f8b<\/h2>\n<p>\u4ee5xml\u4e3a\u4f8b\uff0c\u589e\u52a0\u5b57\u7b26\u4e32\u5904\u7406\u793a\u4f8b\u3002config.xml\u6587\u4ef6\uff1a<br \/>\n<code>&lt;config&gt;<\/code><br \/>\n<code>&lt;host&gt;www.google.com.kh&lt;\/host&gt;<\/code><br \/>\n<code>&lt;port&gt;8080&lt;\/port&gt;<\/code><br \/>\n<code>&lt;\/config&gt;<\/code><br \/>\n<code>&lt;\/code&gt;&lt;\/pre&gt;<\/code><\/p>\n<p>dealContent.bat<\/p>\n<pre><code>\n@echo off  \n  \nrem \u628aconfig.xml\u91cc\u7684<host>127.0.0.1<\/host>\u66ff\u6362\u6210<host>www.google.com.kh<\/host>  \n  \nif exist config_tmp.xml del config_tmp.xml  \n  \nrem \u4f7f\u7528for\u5faa\u73af\u547d\u4ee4\u8bfb\u53d6\u6587\u4ef6\u5185\u5bb9\u65f6\uff0c\u5148\u4ece\u6587\u4ef6\u91cc\u8bfb\u53d6\u4e00\u884c\uff0c\u7136\u540e\u7528\u9ed8\u8ba4\u7684\u5206\u9694\u7b26\u5bf9\u884c\u8fdb\u884c\u5212\u5206\uff0c\u518d\u7528\u5f97\u5230\u7684\u6bcf\u4e00\u9879\u8c03\u7528\u5faa\u73af\u4f53  \nrem \u6240\u4ee5\u8981\u5904\u7406\u7684\u6587\u4ef6\u7684\u884c\u6700\u597d\u4e0d\u8981\u6709\u7a7a\u683c\u6216tab  \n  \nfor \/F %%i in (config.xml) do (  \n    rem \u5982\u679c\u9879\u662fxml\u7684\u6807\u7b7e\uff0c\u8981\u5bf9<>\u8f6c\u4e49  \n    if %%i == ^<host^>127.0.0.1^<\/host^> (  \n        rem >>\u524d\u9762\u662f\u6ca1\u6709\u7a7a\u683c  \n        echo ^<host^>www.google.com.kh^<\/host^>>> config_tmp.xml   \n    ) else (   \n        echo %%i>> config_tmp.xml   \n    )   \n)\n\ndel config.xml\nren config_tmp.xml config.xml\n<\/code><\/pre>\n<h2>\u5b57\u7b26\u4e32\u5904\u7406<\/h2>\n<p>\u4e3b\u8981\u662f\u5b57\u7b26\u4e32\u622a\u53d6\u3001\u66ff\u6362\uff0c\u901a\u8fc7\u66ff\u6362\u5220\u9664\u6307\u5b9a\u5b57\u7b26\u4e32\uff1a<\/p>\n<h3>\u5b57\u7b26\u4e32\u62fc\u63a5<\/h3>\n<p>\u8bed\u6cd5\uff1a<code>newStr=%str1%%str2%<\/code><\/p>\n<pre><code>\nset str1=abc\nset str2=123\nset newStr=%str1%%str2%\necho %newStr%\n<\/code><\/pre>\n<h3>\u5b57\u7b26\u4e32\u622a\u53d6<\/h3>\n<p>\u8bed\u6cd5\uff1a<code>%var:~x,y% (x,y\u2208Z)<\/code>, \u8bf4\u660e\uff1a<\/p>\n<ul>\n<li>\u5f53x\u4e3a\u6b63\u6570\u65f6\u8868\u793a\u4ece\u5de6\u5230\u53f3\u7b2cx+1\u4f4d\u5f00\u59cb\u622a\u53d6\uff0c\u5f53x\u4e3a\u8d1f\u6570\u65f6\u8868\u793a\u4ece\u53f3\u5230\u5de6\u7b2cx\u4f4d\u5f00\u59cb\u622a\u53d6(\u53f3\u4e00\u4f4d\u662f-1)   <\/li>\n<li>\u5f53\u7701\u7565x\u65f6\u91c7\u7528\u9ed8\u8ba4\u503c0\uff1b   <\/li>\n<li>\u5f53y\u4e3a\u6b63\u6570\u65f6\u8868\u793a\u622a\u53d6\u7684\u957f\u5ea6\uff0c\u5f53y\u4e3a\u8d1f\u6570\u65f6\u8868\u793a\u622a\u53d6\u5230\u4ece\u53f3\u5230\u5de6\u7684\u7b2cy+1\u4f4d\uff0c\u5f53\u7701\u7565y\u65f6\u91c7\u7528\u9ed8\u8ba4\u503c-1\u3002<\/li>\n<\/ul>\n<pre><code>\nset src=abc  123 456  \nset trunk=%src:~2,4%  \necho %trunk%  \necho %src:~-5,4%  \n<\/code><\/pre>\n<h3>\u5b57\u7b26\u4e32\u66ff\u6362<\/h3>\n<p>\u8bed\u6cd5\uff1a<code>%var:str1=str2%<\/code><br \/>\n\u8bf4\u660e\uff1a\u5c06\u5b57\u7b26\u4e32var\u4e2d\u6240\u6709\u7684str1\u66ff\u6362\u4e3astr2<br \/>\n  <code>echo %src:123=789%<\/code><\/p>\n<p>\u66ff\u6362\u529f\u80fd\u4e5f\u53ef\u4ee5\u7528\u4e8e\u5b8c\u6210\u5220\u9664\u64cd\u4f5c\uff0c\u53ea\u9700\u8981\u66ff\u6362\u4e3a\u7a7a\u5c31\u884c\u4e86\u3002<\/p>\n<p>\u5220\u9664\u5b57\u7b26\u4e32\u91cc\u7684\u7a7a\u683c<br \/>\n<code>set str5=abc 123 4 5  6 7   8<\/code><br \/>\n<code>echo %str5: =%<\/code><\/p>\n<p>\u5220\u9664\u5b57\u7b26\u4e32\u91cc\u7684tab<br \/>\n<code>echo %str5: =%<\/code><\/p>\n<h2>\u7279\u6b8a\u6807\u8bb0\u7b26\uff1a<\/h2>\n<pre><code>\nCR(0D)      \u547d\u4ee4\u884c\u7ed3\u675f\u7b26  \nSpace(20)   \u7a7a\u683c\uff0c\u5e38\u7528\u7684\u53c2\u6570\u754c\u5b9a\u7b26  \nTab(09)     \u4e0d\u5e38\u7528\u7684\u53c2\u6570\u754c\u5b9a\u7b26  \n+           \u547d\u4ee4\u6587\u4ef6\u8fde\u63a5\u7b26  \n*, ?        \u6587\u4ef6\u901a\u914d\u7b26  \n\"\"          \u5b57\u7b26\u4e32\u754c\u5b9a\u7b26  \n^           \u8f6c\u4e49\u7b26\uff0c\u5176\u540e\u9762\u7684\u7279\u6b8a\u5b57\u7b26\u6309\u539f\u6837\u8f93\u51fa  \n|           \u547d\u4ee4\u7ba1\u9053\u7b26  \n<, >, >>    \u6587\u4ef6\u91cd\u5b9a\u5411\u7b26  \n@           \u547d\u4ee4\u884c\u56de\u663e\u5c4f\u853d\u7b26  \n\/           \u53c2\u6570\u5f00\u5173\u5f15\u5bfc\u7b26  \n:           \u6279\u5904\u7406\u6807\u7b7e\u5f15\u5bfc\u7b26  \n%           \u6279\u5904\u7406\u53d8\u91cf\u5f15\u5bfc\u7b26\n<\/code><\/pre>\n<h2>\u7ec4\u5408\u547d\u4ee4\uff1a<\/h2>\n<p>&amp;<br \/>\nUsage: <code>\u7b2c\u4e00\u6761\u547d\u4ee4 &amp; \u7b2c\u4e8c\u6761\u547d\u4ee4 [&amp; \u7b2c\u4e09\u6761\u547d\u4ee4...]<\/code><br \/>\n\u540c\u65f6\u6267\u884c\u591a\u6761\u547d\u4ee4\uff0c\u800c\u4e0d\u7ba1\u547d\u4ee4\u662f\u5426\u6267\u884c\u6210\u529f\u3002<\/p>\n<p>&amp;&amp;<br \/>\nUsage: <code>\u7b2c\u4e00\u6761\u547d\u4ee4 &amp;&amp; \u7b2c\u4e8c\u6761\u547d\u4ee4 [&amp;&amp; \u7b2c\u4e09\u6761\u547d\u4ee4...]<\/code><br \/>\n\u540c\u65f6\u6267\u884c\u591a\u6761\u547d\u4ee4\uff0c\u5f53\u78b0\u5230\u6267\u884c\u51fa\u9519\u7684\u547d\u4ee4\u5c06\u4e0d\u6267\u884c\u540e\u9762\u7684\u547d\u4ee4\uff0c\u5982\u679c\u4e00\u76f4\u6ca1\u6709\u51fa\u9519\u5219\u4e00\u76f4\u6267\u884c\u5b8c\u6240\u4ee5\u547d\u4ee4\u3002<\/p>\n<p>||<br \/>\nUsage: <code>\u7b2c\u4e00\u6761\u547d\u4ee4 || \u7b2c\u4e8c\u6761\u547d\u4ee4 [|| \u7b2c\u4e09\u6761\u547d\u4ee4...]<\/code><br \/>\n\u540c\u65f6\u6267\u884c\u591a\u6761\u547d\u4ee4\uff0c\u5f53\u78b0\u5230\u6267\u884c\u6b63\u786e\u7684\u547d\u4ee4\u5c06\u4e0d\u6267\u884c\u540e\u9762\u7684\u547d\u4ee4\uff0c\u5982\u679c\u4e00\u76f4\u6ca1\u6709\u51fa\u73b0\u6b63\u786e\u6267\u884c\u7684\u547d\u4ee4\u5219\u4e00\u76f4\u6267\u884c\u5b8c\u6240\u4ee5\u547d\u4ee4\u3002<\/p>\n<h2>| \u7ba1\u9053\u547d\u4ee4<\/h2>\n<p>Usage: \u7b2c\u4e00\u6761\u547d\u4ee4 | \u7b2c\u4e8c\u6761\u547d\u4ee4 [| \u7b2c\u4e09\u6761\u547d\u4ee4&#8230;]<br \/>\n\u5c06\u7b2c\u4e00\u6761\u547d\u4ee4\u7684\u7ed3\u679c\u4f5c\u4e3a\u7b2c\u4e8c\u6761\u547d\u4ee4\u7684\u53c2\u6570\u6765\u4f7f\u7528<br \/>\n<code>sample: netstat -n -p tcp | find \"49194\"<\/code><\/p>\n<h2>\u91cd\u5b9a\u5411<\/h2>\n<p>&#62;, >>, \u8f93\u51fa\u91cd\u5b9a\u5411\u547d\u4ee4<br \/>\n\u5c06\u4e00\u6761\u547d\u4ee4\u6216\u67d0\u4e2a\u7a0b\u5e8f\u8f93\u51fa\u7ed3\u679c\u91cd\u5b9a\u5411\u5230\u7279\u5b9a\u6587\u4ef6\u4e2d\u3002> \u4e0e >> \u7684\u533a\u522b\u5728\u4e8e\uff1a<\/p>\n<ul>\n<li><code>&gt;<\/code>  \u4f1a\u6e05\u9664\u539f\u6709\u6587\u4ef6\u4e2d\u7684\u5185\u5bb9\u540e\u5199\u5165\u6307\u5b9a\u6587\u4ef6\uff0c  <\/li>\n<li><code>&gt;&gt;<\/code> \u53ea\u4f1a\u8ffd\u52a0\u5185\u5bb9\u5230\u6307\u5b9a\u6587\u4ef6\u4e2d\uff0c\u800c\u4e0d\u4f1a\u6539\u53d8\u5176\u4e2d\u7684\u5185\u5bb9\u3002  <\/li>\n<\/ul>\n<p>&lt;, >&amp;, &lt;&amp;<br \/>\n<code>&lt;<\/code>  \u4ece\u6587\u4ef6\u4e2d\u800c\u4e0d\u662f\u952e\u76d8\u4e2d\u8bfb\u5165\u547d\u4ee4\u8f93\u5165\u3002<\/p>\n<p><code>&gt;&amp;<\/code> \u5c06\u4e00\u4e2a\u53e5\u67c4\u7684\u8f93\u51fa\u5199\u5165\u5230\u53e6\u4e00\u4e2a\u53e5\u67c4\u7684\u8f93\u5165\u4e2d\u3002<\/p>\n<p><code>&lt;&amp;<\/code> \u4ece\u4e00\u4e2a\u53e5\u67c4\u8bfb\u5165\u8f93\u5165\u5e76\u5c06\u5176\u5199\u5165\u5230\u53e6\u4e00\u4e2a\u53e5\u67c4\u8f93\u51fa\u4e2d\u3002<\/p>\n<h2>set \u547d\u4ee4\u8fdb\u9636<\/h2>\n<h3>\u8bf4\u660e<\/h3>\n<p><code>set [[\/a [expression]] [\/p [variable=]] string]<\/code><br \/>\n\u53c2\u6570\u8bf4\u660e<\/p>\n<pre><code>\/a :  \u5c06string\u8bbe\u7f6e\u6210\u53ef\u6c42\u503c\u7684\u6570\u5b57\u8868\u8fbe\u5f0f  \n\/p :   \u5c06variable\u7684\u503c\u8bbe\u7f6e\u6210\u8f93\u5165\u884c  \nvariable : \u6307\u5b9a\u9700\u8981\u8bbe\u7f6e\u6216\u4fee\u6539\u7684\u53d8\u91cf  \nstring :  \u6307\u5b9a\u8981\u4e0e\u53d8\u91cf\u5173\u8054\u7684\u5b57\u7b26\u4e32  \n\/? : \u5728\u547d\u4ee4\u63d0\u793a\u7b26\u663e\u793a\u5e2e\u52a9  \n<\/code><\/pre>\n<h3>\u6570\u5b57\u8868\u8fbe\u5f0f\u6c42\u503c(\u4f7f\u7528\/a)<\/h3>\n<p><code>rem  set \/a expression<\/code>, set\u7684\/a\u53c2\u6570\u5c31\u662f\u8ba9set\u53ef\u4ee5\u652f\u6301\u6570\u5b66\u7b26\u53f7\u8fdb\u884c\u6570\u5b66\u8fd0\u7b97\uff0c\u6570\u503c\u9ed8\u8ba4\u662f10\u8fdb\u5236\uff0c\u524d\u7f000x\u8868\u793a\u5341\u516d\u8fdb\u5236\uff0c0\u8868\u793a\u516b\u8fdb\u5236\u6570\u5b57\u3002<\/p>\n<p>\u6309\u4f18\u5148\u7ea7\u4ece\u9ad8\u5230\u4f4e\uff1a<\/p>\n<pre><code>\u8fd0\u7b97\u7b26             \u6267\u884c\u7684\u64cd\u4f5c  \n()                 \u5206\u7ec4  \n+-*\/%              \u7b97\u6cd5  \n&lt;&lt;  &gt;&gt;             \u903b\u8f91\u79fb\u4f4d  \n&amp; | ^              \u4f4d\u8fd0\u7b97  \n+ += -= *= \/= %= &amp;= ^= |= &lt;&lt;= &gt;&gt;= \u8d4b\u503c  \n,                  \u8868\u8fbe\u5f0f\u5206\u9694\u7b26  \n<\/code><\/pre>\n<p>\u5982\u679c\u4f7f\u7528\u903b\u8f91(&amp;|)\u6216\u6a21(%)\u8fd0\u7b97\u7b26\uff0c\u8981\u7528\u5f15\u53f7\u5c06\u8868\u8fbe\u5f0f\u5b57\u7b26\u4e32\u5f15\u8d77\u6765\u3002\u8868\u8fbe\u5f0f\u4e2d\u7684\u975e\u6570\u5b57\u5b57\u7b26\u4e32\u5c06\u88ab\u89c6\u4e3a\u73af\u5883\u53d8\u91cf\u540d<\/p>\n<p>(\u8fd0\u884c\u5bf9\u73af\u5883\u53d8\u91cf\u8fdb\u884c\u7b97\u672f\u8fd0\u7b97\uff0c\u800c\u4e0d\u9700\u8981\u4f7f\u7528%)\uff0c\u5176\u503c\u5c06\u88ab\u8f6c\u5316\u6210\u6570\u5b57\u7136\u540e\u8fdb\u884c\u5904\u7406\u3002\u5982\u679c\u6307\u5b9a\u7684\u5f53\u524d\u73af\u5883\u4e2d<\/p>\n<p>\u6ca1\u6709\u5b9a\u4e49\u7684\u73af\u5883\u53d8\u91cf\u540d\uff0c\u5c06\u4f1a\u5206\u914d\u96f6\u503c\u3002<\/p>\n<h3>\u63d0\u4f9b\u4ea4\u4e92\u754c\u9762(\u4f7f\u7528\/p)<\/h3>\n<p><code>set \/p var=\u8bf7\u8f93\u5165\u53d8\u91cf\u7684\u503c\uff1a<\/code><br \/>\n<code>echo %var%<\/code><\/p>\n<h2>\u53d8\u91cf\u589e\u5f3a<\/h2>\n<p>\u7528 <code>if [not] defined variable<\/code> \u53ef\u4ee5\u5224\u65ad\u53d8\u91cf\u662f\u5426\u6709\u5185\u5bb9<\/p>\n<h3>\u73af\u5883\u53d8\u91cf<\/h3>\n<p>\u5982\u679c\u6ca1\u6709\u4efb\u4f55\u53c2\u6570\uff0cset\u547d\u4ee4\u5c06\u663e\u793a\u5f53\u524d\u73af\u5883\u53d8\u91cf<br \/>\n\u5f53\u6307\u5b9a\u53d8\u91cf\u548c\u5b57\u7b26\u4e32\u7684\u503c\u65f6\uff0c\u6307\u5b9a\u7684\u53d8\u91cf\u503c\u5c06\u88ab\u6dfb\u52a0\u5230\u8be5\u73af\u5883\uff0c\u800c\u4e14\u8be5\u5b57\u7b26\u4e32\u4e0e\u8be5\u53d8\u91cf\u5173\u8054\u3002\u5982\u679c\u73af\u5883\u4e2d\u5df2\u5b58\u5728\u8be5\u53d8\u91cf\uff0c\u65b0\u7684\u5b57\u7b26\u4e32\u503c\u5c06\u66ff\u4ee3\u65e7\u7684\u5b57\u7b26\u4e32\u503c\u3002<br \/>\n\u5982\u679c\u53ea\u4e3aset\u547d\u4ee4\u6307\u5b9a\u4e00\u4e2a\u53d8\u91cf\u548c\u4e00\u4e2a\u7b49\u53f7(\u6ca1\u6709\u5b57\u7b26\u4e32)\uff0c\u5219\u4e0e\u8be5\u53d8\u91cf\u5173\u8054\u7684\u5b57\u7b26\u4e32\u503c\u5c06\u88ab\u6d88\u9664(\u5c31\u50cf\u53d8\u91cf\u6839\u672c\u4e0d\u5b58\u5728\u4e00\u6837)<\/p>\n<h3>\u5ef6\u8fdf\u73af\u5883\u53d8\u91cf\u8bf4\u660e\u4e0e\u542f\u7528<\/h3>\n<p>\u5ef6\u8fdf\u73af\u5883\u53d8\u91cf\u6269\u5c55\u7684\u529f\u80fd\uff0c\u5373\u53d8\u91cf\u5ef6\u8fdf\u89e3\u6790\u529f\u80fd\u3002\u6b64\u529f\u80fd\u9ed8\u8ba4\u662f\u505c\u7528\u7684\uff0c\u53ef\u4ee5\u8c08\u8fc7<code>cmd.exe \/V<\/code> \u6216<br \/>\n<code>setlocal EnableDelayedExpansion<\/code>\u6765\u5f00\u542f\u3002\u4f7f\u7528\u5ef6\u8fdf\u53d8\u91cf\u65f6\u9700\u8981\u7528&#8221;!&#8221;\u62ec\u8d77\u3002<\/p>\n<h3>\u52a8\u6001\u73af\u5883\u53d8\u91cf<\/h3>\n<pre><code>\u53d8\u91cf        \u8bf4\u660e  \n%CD%                \u6269\u5145\u4e3a\u5f53\u524d\u76ee\u5f55  \n%DATE%              \u6269\u5145\u4e3a\u5f53\u524d\u65e5\u671f  \n%TIME%              \u6269\u5145\u4e3a\u5f53\u524d\u65f6\u95f4  \n%RANDOM%            \u6269\u5145\u4e3a0\u523032767\u7684\u968f\u673a\u6570  \n%ERRORLEVEL%        \u6269\u5145\u4e3a\u5f53\u524d\u547d\u4ee4\u5904\u7406\u5668\u547d\u4ee4\u6269\u5c55\u7248\u672c\u53f7  \n%CMDCMDLINE%        \u6269\u5145\u4e3a\u8c03\u7528\u547d\u4ee4\u5904\u7406\u5668\u7684\u539f\u59cb\u547d\u4ee4\u884c\uff0c\u5373\u63a7\u5236\u53f0\u8def\u5f84  \n<\/code><\/pre>\n<h3>\u53d8\u91cf\u589e\u5f3a(\u6587\u4ef6\u540d\u8def\u5f84\u5904\u7406)<\/h3>\n<pre><code>\u53d8\u91cf          \u8bf4\u660e  \n%~I            \u6269\u5145%I\u4e3a\u5220\u9664\u5916\u56f4\"\u5f15\u53f7(\u6709\u5c31\u5220)  \n%~fI           \u6269\u5145%I\u4e3a\u4e00\u4e2a\u5b8c\u6574\u7684\u8def\u5f84  \n%~dI           \u4ec5\u6269\u5145%I\u4e3a\u4e00\u4e2a\u9a71\u52a8\u5668\u53f7  \n%~pI           \u4ec5\u6269\u5145%I\u4e3a\u4e00\u4e2a\u8def\u5f84  \n%~nI           \u4ec5\u6269\u5145%I\u4e3a\u4e00\u4e2a\u6587\u4ef6\u540d  \n%~xI           \u4ec5\u6269\u5145%I\u4e3a\u4e00\u4e2a\u6587\u4ef6\u6269\u5c55\u540d  \n%~sI           \u6269\u5145%I\u4e3a\u5b8c\u6574\u7684\u77ed\u547d\u8def\u5f84  \n%~aI           \u6269\u5145\u4e3a\u6587\u4ef6\u7684\u5c5e\u6027(arsh)  \n%~$PATH:I      \u53d8\u91cf\u53ef\u4ee5\u662f\u5176\u4ed6\u7684\uff0c\u5982\uff1awindDir\u3001programfiles\u7b49\u5728\u73af\u5883\u53d8\u91cfPATH\u6307\u5b9a\u7684\u8def\u5f84\u603b\u641c\u7d22\u6587\u4ef6\uff0c\u6269\u5145%I\u4e3a\u627e\u5230\u7684\u7b2c\u4e00\u4e2a\u6587\u4ef6\u7684\u5b8c\u6574\u8def\u5f84\uff1b\u82e5\u672a\u627e\u5230\u6587\u4ef6\uff0c\u5219\u6269\u5145%I\u4e3a\u7a7a\u3002  \n<\/code><\/pre>\n<p>\u7ec4\u5408\u6269\u5c55\u53c2\u6570\u6548\u679c\uff1a<\/p>\n<pre><code>%~dpI:     \u4ec5\u6269\u5145%I\u4e3a\u9a71\u52a8\u5668\u53f7\u548c\u8def\u5f84  \n%~nxI:     \u4ec5\u6269\u5145%I\u4e3a\u6587\u4ef6\u540d\u52a0\u6269\u5c55\u540d  \n%~fsI:     \u6269\u5145%I\u4e3a\u5b8c\u6574\u7684\u77ed\u540d\u8def\u5f84(%~sI)  \n<\/code><\/pre>\n<h2>\u7528\u6279\u5904\u7406\u8c03\u7528yuicompressor\u538b\u7f29js\u3001css\u7684\u811a\u672c<\/h2>\n<pre><code>\n@echo off  \nsetlocal enabledelayedexpansion\n\nset pwd=%CD%\nset srcDir=%pwd%\\testcompress\nset dstDir=%pwd%\\testcompressres\n\ndel \/F \/Q \/S %dstDir%\\*\n  \nfor \/R %srcDir% %%D in (*) do (  \n    set pth=%%~dpD  \n    set pth=!pth:%srcDir%=%dstDir%!  \n    set fname=%%~nD  \n    set ext=%%~xD  \n  \n    if not exist !pth!  mkdir !pth!  \n      \n    set dst=!pth!!fname!!ext!  \n      \n    if \/I \"!ext!\" == \".css\" (  \n        java -jar yuicompressor-2.4.7\\build\\yuicompressor-2.4.7.jar --charset utf8 --type css -o !dst! %%D  \n    ) else if \"!ext!\" == \".js\" (  \n        java -jar yuicompressor-2.4.7\\build\\yuicompressor-2.4.7.jar --charset utf8 --type js  -o !dst! %%D  \n    )  \n)\n<\/code><\/pre>\n<h2>\u539f\u59cb\u94fe\u63a5<\/h2>\n<p>\u8fd9\u4e9b\u7b14\u8bb0\u4e4b\u524d\u5df2\u53d1\u8868\u5728iteye\u4e0a\uff0c\u91cd\u65b0\u6574\u7406\u6210markdown\u683c\u5f0f\uff0c\u4e5f\u5f53\u662f\u590d\u4e60\u4e86\u3002<\/p>\n<p>\u6279\u5904\u7406 \u7b14\u8bb0\uff1a <a href=\"http:\/\/wen866595.iteye.com\/admin\/blogs\/1683913\">http:\/\/wen866595.iteye.com\/admin\/blogs\/1683913<\/a><\/p>\n<p>\u66f4\u591a\u6279\u5904\u7406\uff1a <a href=\"http:\/\/wen866595.iteye.com\/admin\/blogs\/1706662\">http:\/\/wen866595.iteye.com\/admin\/blogs\/1706662<\/a><\/p>\n<hr\/>\n<p>\u6b22\u8fce\u5173\u6ce8\u6211\u7684\u5fae\u4fe1\u516c\u4f17\u53f7: <strong>coderbee\u7b14\u8bb0<\/strong>\uff0c\u53ef\u4ee5\u66f4\u53ca\u65f6\u56de\u590d\u4f60\u7684\u8ba8\u8bba\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"258\" height=\"258\" src=\"https:\/\/coderbee.net\/wp-content\/uploads\/2019\/01\/coderbee-note.jpg\" class=\"alignnone size-full wp-image-1707\"><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6279\u5904\u7406\u53ef\u4ee5\u8bf4\u662fwindows\u4e0b\u7684shell\uff0c\u867d\u7136\u6ca1\u6709shell\u5f3a\u5927\u5427\uff0c\u4f46\u4e5f\u8db3\u4ee5\u7528 &hellip; <a href=\"https:\/\/coderbee.net\/index.php\/windows\/20130424\/45\">\u7ee7\u7eed\u9605\u8bfb <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[13],"tags":[14,15],"_links":{"self":[{"href":"https:\/\/coderbee.net\/index.php\/wp-json\/wp\/v2\/posts\/45"}],"collection":[{"href":"https:\/\/coderbee.net\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/coderbee.net\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/coderbee.net\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/coderbee.net\/index.php\/wp-json\/wp\/v2\/comments?post=45"}],"version-history":[{"count":3,"href":"https:\/\/coderbee.net\/index.php\/wp-json\/wp\/v2\/posts\/45\/revisions"}],"predecessor-version":[{"id":48,"href":"https:\/\/coderbee.net\/index.php\/wp-json\/wp\/v2\/posts\/45\/revisions\/48"}],"wp:attachment":[{"href":"https:\/\/coderbee.net\/index.php\/wp-json\/wp\/v2\/media?parent=45"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/coderbee.net\/index.php\/wp-json\/wp\/v2\/categories?post=45"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/coderbee.net\/index.php\/wp-json\/wp\/v2\/tags?post=45"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}