a262615704 当前离线
列兵
评分人数
FOR 当前离线
中尉
gawk -F\" "{print $1}" a.txt复制代码
TOP
awk 当前离线
上尉
CrLf 当前离线
论坛巡查
@echo off&setlocal enabledelayedexpansion for /f "eol= tokens=2 delims=()" %%a in (info.txt) do ( set /a n+=1 set disk!n!=%%a ) echo 磁盘数量:%n% for /l %%a in (1 1 %n%) do echo 磁盘%%a的容量是!disk%%a! pause复制代码
@echo off setlocal enabledelayedexpansion for /f "tokens=1-3 delims=() " %%a in (info.txt) do ( if "%%a" == "Disk:" ( set /a value+=1 set info!value!=磁盘%%b的容量是%%c ) ) echo 磁盘总数是%value% for /l %%a in (1,1,%value%) do ( echo !info%%a! ) pause复制代码
Hello123World 当前离线
荣誉版主
@echo off&Setlocal EnableDelayedExpansion For /f "tokens=1,2 delims=()" %%i in ('Findstr /i "disk" 1.txt') do ( Set /a n+=1 Echo %%i 容量 %%j ) echo 合计磁盘数:!n! pause复制代码
gawk -F"[() ]" "/Disk:/{n=$2;a[n]=$4}END{print \"磁盘数量:\"n;for(i=1;i<=n;i++)print \"磁盘\"i\"的容量:\"a[i]}" info.txt | more复制代码
601997526 当前离线
六级士官
@echo off for /f "tokens=2 delims=:()" %%i in ('findstr "^Disk:" info.txt') do set disk=%%i echo 磁盘数量:%disk% for /f "tokens=2,3 delims=:()" %%i in ('findstr "^Disk:" info.txt') do echo.磁盘%%i的容量:%%j pause复制代码