WindowsϵͳÖÐcmdÏÂÁîµÄ¸ß¼¶¹¦Ð§ÏÈÈÝ
Windows²Ù×÷ϵͳÖеÄCommand Prompt£¨ÏÂÁîÌáÐÑ·û£©ÊÇÒ»¸öÇ¿Ê¢µÄ¹¤¾ß£¬¿ÉÒÔÈÃÓû§Í¨¹ýÏÂÁîÀ´¿ØÖÆÅÌËã»ú²¢Ö´ÐÐÖݪֲÙ×÷¡£³ýÁË»ù±¾µÄÏÂÁîÍ⣬Command Prompt»¹ÌṩÁËÐí¶à¸ß¼¶¹¦Ð§£¬±¾ÎĽ«ÏÈÈÝһЩ³£Óõĸ߼¶¹¦Ð§²¢ÌṩÏêϸµÄ´úÂëʾÀý¡£
1. ¹ÜµÀ²Ù×÷·û£¨|£©
¹ÜµÀ²Ù×÷·ûÓÃÓÚ½«Ò»¸öÏÂÁîµÄÊä³ö×÷ΪÁíÒ»¸öÏÂÁîµÄÊäÈ룬ʵÏÖÏÂÁîÖ®¼äµÄÅþÁ¬¡£ÀýÈ磬¿ÉÒÔͨ¹ý¹ÜµÀ½«Ò»¸öÏÂÁîµÄÊä³öЧ¹ûת´ï¸øÁíÒ»¸öÏÂÁî¾ÙÐйýÂË»ò´¦Àí¡£
ʾÀý´úÂ룺
dir | find ".txt"
µÇ¼ºó¸´ÖÆ
ÉÏÊö´úÂ뽫ÁгöÄ¿½ñĿ¼ÏµÄËùÓÐÎļþ£¬²¢Ê¹ÓÃfindÏÂÁî¹ýÂ˳ö°üÀ¨¡°.txt¡±ºó׺µÄÎļþ¡£
2. Öض¨Ïò²Ù×÷·û£¨>¡¢>>£©
Öض¨Ïò²Ù×÷·ûÓÃÓÚ½«ÏÂÁîµÄÊä³öЧ¹ûÉúÑĵ½Îļþ»ò½«ÎļþÄÚÈÝ×÷ΪÏÂÁîµÄÊäÈë¡£>ÓÃÓÚÁýÕÖÔÓÐÎļþÄÚÈÝ£¬>>ÓÃÓÚÔÚÔÓÐÎļþÄÚÈݵÄĩβ׷¼ÓÐÂÄÚÈÝ¡£
ʾÀý´úÂ룺
dir > filelist.txt
µÇ¼ºó¸´ÖÆ
ÉÏÊö´úÂ뽫Ŀ½ñĿ¼ÏµÄÎļþÁбíÉúÑĵ½ÃûΪfilelist.txtµÄÎļþÖС£
3. Åú´¦ÀíÎļþ£¨.bat£©
Åú´¦ÀíÎļþÊÇ°üÀ¨ÁËһϵÁÐÏÂÁîµÄÎı¾Îļþ£¬¿ÉÒÔÒ»´ÎÐÔÖ´Ðжà¸öÏÂÁͨ¹ýÅú´¦ÀíÎļþ£¬Óû§¿ÉÒÔ×Ô¶¯»¯Ö´ÐÐһϵÁвÙ×÷£¬Ìá¸ßÊÂÇéЧÂÊ¡£
ʾÀý´úÂ룺
@echo off echo Hello, World! pause
µÇ¼ºó¸´ÖÆ
ÉÏÊö´úÂ뽫Êä³ö¡°Hello, World!¡±²¢ÔÚÓû§°´í§Òâ¼üºóÔÝÍ£Ö´ÐС£
4. forÑ»·ÏÂÁî
forÑ»·ÏÂÁîÓÃÓÚ±éÀúÖ¸¶¨µÄÎļþ»òĿ¼£¬²¢¶Ôÿ¸öÏîÖ´ÐÐÌض¨²Ù×÷¡£
ʾÀý´úÂ룺
for /f "tokens=*" %i in (filelist.txt) do echo %i
µÇ¼ºó¸´ÖÆ
ÉÏÊö´úÂ뽫·¿ªfilelist.txtÎļþ£¬Ñ»·Ã¿Ò»Ðв¢Êä³ö¡£
5. Ìõ¼þÅжÏÓï¾ä£¨if£©
Ìõ¼þÅжÏÓï¾ä¿ÉÒÔƾ֤Ìõ¼þÀ´Ö´Ðвî±ðµÄÏÂÁʵÏÖÁ÷³Ì¿ØÖÆ¡£
ʾÀý´úÂ룺
set var=10 if %var%==10 ( echo Var is 10 ) else ( echo Var is not 10 )
µÇ¼ºó¸´ÖÆ
ÉÏÊö´úÂ뽫ƾ֤±äÁ¿varµÄÖµÊä³ö²î±ðµÄЧ¹û¡£
½áÓï
WindowsϵͳÖеÄÏÂÁîÌáÐÑ·ûÌṩÁ˸»ºñµÄ¹¦Ð§£¬¿ÉÒÔ×ÊÖúÓû§¸ü¸ßЧµØÖÎÀíÎļþºÍÖ´ÐвÙ×÷¡£Í¨¹ýÕÆÎÕÕâЩ¸ß¼¶¹¦Ð§£¬²¢ÍŽáÏêϸµÄ´úÂëʾÀý£¬¿ÉÒÔ½øÒ»²½ÌáÉýÊÂÇéЧÂʺͲÙ×÷ÎÞаÐÔ¡£Ï£Íû±¾ÎÄÌṩµÄÄÚÈÝÄܹ»×ÊÖú¶ÁÕßÔ½·¢ÊìÁ·µØÔËÓÃÏÂÁîÌáÐÑ·û¹¤¾ß¡£
ÒÔÉϾÍÊÇWindowsϵͳÖÐcmdÏÂÁîµÄ¸ß¼¶¹¦Ð§ÏÈÈݵÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡