echo命令中有6个分隔符,分别是:“./\=;,”
C:\Users\helloworld\Desktop>echo.
C:\Users\helloworld\Desktop>echo\
C:\Users\helloworld\Desktop>echo/
C:\Users\helloworld\Desktop>echo=
C:\Users\helloworld\Desktop>echo;
C:\Users\helloworld\Desktop>echo,
C:\Users\helloworld\Desktop>md 1,2
C:\Users\helloworld\Desktop>md 3=4
C:\Users\helloworld\Desktop>md 5;6
C:\Users\helloworld\Desktop>md 7 8
C:\Users\helloworld\Desktop>rd 1,2
C:\Users\helloworld\Desktop>rd 3=4
C:\Users\helloworld\Desktop>rd 5;6
C:\Users\helloworld\Desktop>rd 7 8
再检测del命令的分隔符:
1.创建文本,供del删除;
C:\Users\helloworld\Desktop>for /l %i in (12;1;21) do @echo\ >%i.txt
2.检测del的分隔符;
C:\Users\helloworld\Desktop>del 12.txt=13.txt
C:\Users\helloworld\Desktop>del 14.txt;15.txt
C:\Users\helloworld\Desktop>del 16.txt,17.txt
C:\Users\helloworld\Desktop>del 18.txt/19.txt
无效开关 - "19.txt"。
C:\Users\helloworld\Desktop>del 18.txt\19.txt
目录名称无效。
C:\Users\helloworld\Desktop>del 18.txt.19.txt
找不到 C:\Users\helloworld\Desktop\18.txt.19.txt
C:\Users\helloworld\Desktop>del 18.txt 19.txt
3.检测结果
不难看出,del的分割符也是4个,分别是:“,;=空格”
这里大胆的提出一个假设,“,;=空格”4个分隔符是系统级的,在与命令语法不冲突的前提下(例:echo与空格),可以在任意命令中作为分隔符使用。
用for反证一下:
1.txt复制代码 code1- @echo off
- For /f "tokens=1-2 delims=:" %%i in ('Findstr /n ".*" "1.txt"') do echo %%i=%%j
- pause
复制代码 code2- @echo off
- For /f "tokens=1-2;delims=:" %%i in ('Findstr /n ".*" "1.txt"') do echo %%i=%%j
- pause
复制代码 code2,提示出错“此时不应有 ;delims=:"”
换成=号,“此时不应有 =delims=:"”
换成,号,“此时不应有 delims=:"”
|