- @echo off
- setlocal enabledelayedexpansion
- for /f "delims=" %%a in ('type 1.txt') do (
- set /a m+=1
- set "home!m!=%%a" -------------------------1.为什么会有个home? 为什么双引号在整个式子的两边,而不为''home!m!''=''%%a''?
- )
- for /f "delims=" %%b in ('type 2.txt') do (
- set /a n+=1
- set "bat!n!=%%b" ---------------------------------2.为什么会有bat,同第一问
- )
- if %m% gtr %n% (
- for /l %%c in (1 1 %m%) do (
- if not "!home%%c!"=="" echo !home%%c! ------------这里的 !home%%c!代表什么?
- if not "!bat%%c!"=="" echo !bat%%c!
- )
- ) else (
- for /l %%d in (1 1 %n%) do (
- if not "!home%%d!"=="" echo !home%%d!
- if not "!bat%%d!"=="" echo !bat%%d!
- )
- )
- pause
复制代码
- @echo off
- for /f "delims=" %%i in (1.txt) do set /a n+=1&call,set "_%%n%%=%%i" ---------------为什么参数n会跟参数i相等,参数n不是数字吗,参数i不是文本内容吗,他们两怎么会相等?
- for /f "delims=" %%i in (2.txt) do set /a m+=1&call,set ".%%m%%=%%i" ----------------为什么 ".%%m%%=%%i"中会有 . 上面的第二段代码为什么"_%%n%%=%%i" 中会有 _
- if %n% gtr %m% (set "num=%n%") else (set "num=%m%")
- for /l %%i in (1,1,%num%) do (
- if defined _%%i call,echo %%_%%i%% ------------------defined后面的参数为什么会有_(_%%i)
- if defined .%%i call,echo %%.%%i%% ------------------defined后面的参数为什么会有.(.%%i )[attach]5580[/attach]
- )
- pause>nul
-
-
复制代码
|