批处理练习题_usb测试批处理
批处理练习题由刀豆文库小编整理,希望给你工作、学习、生活带来方便,猜你可能喜欢“usb测试批处理”。
批处理实现两文本同行交替输出
有两个文本如下(实际中并不知道两文本各有多少行): 文本1.txt aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa ccccccccccccccccccccccccccccccccccccccc eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee ggggggggggggggggggggggggggggggggggggggg www.daodoc.come easy]
I should have known all along.There was something wrong.I just never read between the lines.Then I woke up one day and found you on your way.Leaving nothing but my heart behind.What can I do to make it up to you.Promises don't come easy.But tell me if there's a way to bring you back home to stay.Well I'd promises anything to you.I've been walkin' around with my head hanging down.Wondrin' what I'm gonna do.'Cause when you walked out that door.要求,CMD原始窗口中,不调节窗口大小,不生成临时文件,居中显示文本内容。输出如下: 代码: [Promise don't come easy] I should have known all along.There was something wrong.I just never read between the lines.Then I woke up one day and found you on your way.Leaving nothing but my heart behind.What can I do to make it up to you.Promises don't come easy.But tell me if there's a way to bring you back home to stay.Well I'd promises anything to you.I've been walkin' around with my head hanging down.Wondrin' what I'm gonna do.'Cause when you walked out that door.@echo off copy /y 1.txt 2.txt>nul echo.>>2.txt&echo end>>2.txt for /f “tokens=1,2* delims=: ” %%i in('findstr /n /o.* 2.txt')do(set “_%%i=%%j”&set “.%%i=%%k”
if %%i geq 2 call :lp %%i)del /q 2.txt&pause>nul&goto :eof :lp set /a n=%1-1 set /a num=_%1-_%n%-2 set /a kl=(80-num)/2 for /l %%i in(1,1,%kl%)do set /p=
批处理去除指定字符前所有的0 如文本1.txt: 代码: 0000acb0h 0b0c00a000s 0000h00ga00 a0000000 通过批处理将文本所有字符串字符a前的0去除输出如下: 代码: acb0h bca000s hga00 a0000000 要求:代码简洁、高效、通用,不生成临时文件
@echo off for /f “delims=” %%.in(1.txt)do(set “str=%%.” call,set “str=%%str:*a=%%” for /f “delims=a” %%{ in(“%%.”)do(set “var=%%{” call,echo.%%var:0=%%a%%str%%))pause>nul
@echo off for /f “tokens=1,2 delims=a” %%i in(1.txt)do(if “%%j” neq “”(set “str=%%i” call,set “str=%%str:0=%%” call,echo %%str%%a%%j)else(echo a%%i))pause>nul