批处理脚本从文本文件复制x行而没有尾随空格

时间:2022-09-28 02:07:10

im trying to copy the first x lines
but when i open list1 i see spaces after each line
i'd like to have no space after each lines

我试图复制前x行,但当我打开list1时,我看到每行之后的空格我想在每行之后没有空格

for /F "eol=; tokens=1 delims=;" %%I in (text.txt) do (
    set /a count+=1
    if !count! leq 10 echo %%I>>list1
)

1 个解决方案

#1


0  

Try this instead:

试试这个:

for /F "eol=; tokens=1 delims=; " %%I in (text.txt) do (
  set /a count+=1
  if !count! leq 10 echo %%I>>list1
)

Note the space in 'delims=; '.

注意'delims =中的空格; ”。

#1


0  

Try this instead:

试试这个:

for /F "eol=; tokens=1 delims=; " %%I in (text.txt) do (
  set /a count+=1
  if !count! leq 10 echo %%I>>list1
)

Note the space in 'delims=; '.

注意'delims =中的空格; ”。