![]() |
China DOS Union-- Unite DOS · Advance DOS · Grow DOS --Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum |
| Guest | Log in | Register | Members | Search | China DOS Union |
|
中国DOS联盟论坛 The time now is 2026-08-08 02:45 |
48,041 topics / 350,128 posts / today 3 new / 48,253 members |
| DOS批处理 & 脚本技术(批处理室) » How can the echo command in DOS be made to not automatically append a newline when outputting? |
| Printable Version 1,761 / 4 |
| Floor1 kingkinglh | Posted 2007-10-25 14:15 |
| 新手上路 Posts 5 Credits 16 | |
|
To generate a file a.txt with the content "123456" using the for /l command, you can modify the command as follows:
```batch @echo off setlocal enabledelayedexpansion set "str=" for /l %%d in (1,1,6) do ( set "str=!str!%%d" ) echo !str!>a.txt endlocal ``` This code first initializes an empty string, then appends each number from 1 to 6 to the string within the loop. Finally, it echoes the concatenated string to the file a.txt, thus avoiding the line breaks. |
|
| Floor2 ssikiki | Posted 2008-04-07 22:56 |
| 新手上路 Posts 2 Credits 4 | |
|
setlocal enabledelayedexpansion
set str= for /l %%d in (1,1,6) do set str=!str!%%d echo !str! pause |
|
| Floor3 9527 | Posted 2008-04-07 23:32 |
| 银牌会员 Posts 438 Credits 1,185 From 北京 | |
|
```
for /l %a in (1,1,6) do @<nul,set/p=%a ``` |
|
| Floor4 abcd | Posted 2008-04-07 23:35 |
| 银牌会员 Posts 739 Credits 1,436 | |
|
95 is quite not bad, o(∩_∩)o... Haha
|
|
| Floor5 chishingchan | Posted 2008-04-10 21:41 |
| 银牌会员 Posts 538 Credits 1,284 | |
|
[ Contact the Union admin team -
中国DOS联盟 -
Standard version ] Sponsored by ifanr Inc | © 2001–2023 |