When I try to run file.cmd
containing the following:
for /l %m in (1,1,1) do @for /f "tokens=1,2* delims=:" %a in ('findstr /n /r "^" csv\data.csv ^| findstr /r "^%m:"') do @echo %b >csv\header.csv
I get this error:
" m:")'. Unexpected at this time
But when I run that same command at a command prompt (no .cmd
file), it works.
You realize there is a much much much simpler way to get the first line of a file into a variable.
set /p header=<data.csv
echo %header%>header.csv
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.