|
hhasee
初级用户
积分 185
发帖 88
注册 2008-5-12
状态 离线
|
『楼 主』:
关于输出换行的问题
现在我想用ECHO命令将相关字符写入一个文本文件后,发现每一条命令输完后就会换行,示例如下:
ECHO 123 >>1.TXT
ECHO ABC >>1.TXT
此时文本中显示的结果为下:
123
ABC
而我想要的是123ABC,最好是123 ABC(中间多一个空格),本来用
set /p =123<nul >>1.txt
set /p =ABC<nul >>1.txt
在XP下可以完成,但在纯DOS下时就不行,不知哪位高手能指点一下,也可发邮件给我:zhoubin-01@tom.com ,在此不胜感谢!!!!!
|
|
2008-9-18 17:19 |
|
|
huahua0919
银牌会员
积分 1608
发帖 780
注册 2007-10-7
状态 离线
|
|
2008-9-18 17:22 |
|
|
hhasee
初级用户
积分 185
发帖 88
注册 2008-5-12
状态 离线
|
『第
3 楼』:
谢谢楼上的,我说的是分别执行两个命令,不是一次执行完!不知有没有高手指导一下啊!
|
|
2008-9-18 20:08 |
|
|
DOSforever
金牌会员
积分 4639
发帖 2239
注册 2005-1-30
状态 离线
|
|
2008-9-19 00:51 |
|
|
hhasee
初级用户
积分 185
发帖 88
注册 2008-5-12
状态 离线
|
『第
5 楼』:
OK,俺们删除!在线等侯!...
|
|
2008-9-19 07:59 |
|
|
hhasee
初级用户
积分 185
发帖 88
注册 2008-5-12
状态 离线
|
『第
6 楼』:
删除了,能回答了吗?
[ Last edited by hhasee on 2008-9-19 at 08:20 AM ]
|
|
2008-9-19 08:10 |
|
|
DOSforever
金牌会员
积分 4639
发帖 2239
注册 2005-1-30
状态 离线
|
『第
7 楼』:
可以用 4DOS 的 echos 命令
Quote: | 4DOS Help Topic: ECHOS
Purpose: Display a message without a trailing carriage return and line
feed.
Format: ECHOS message
message: Text to display.
See also: ECHO, ECHOERR, ECHOSERR, SCREEN, SCRPUT, TEXT, and VSCRPUT.
Usage
ECHOS is useful for text output when you don't want to add a carriage return
and line feed at the end of the line. For example, you can use ECHOS when
you need to redirect control sequences to your printer; this example sends
the sequence Esc P to the printer on LPT1:
c:\> echos eP > lpt1:
To include the command separator character [^] or the redirection and piping
symbols [<>|] in an ECHOS message, enclose them in quotes (see Argument
Quoting) or precede them with the escape character.
If you want to embed a carriage return or other control character in the
message, you can use the @CHAR function or an escape sequence. For
instance, you might wish to print a carriage return at the start of your
message to move the cursor to the start of the line, so you can overwrite
text already on the screen. Use @CHAR[13] or %=r to print a carriage
return:
do i = 100 to 0 by -1
echos %=r%i` `
delay /m 1
enddo
ECHOS does not translate or modify the message text. For example, carriage
return characters are not translated to CR/LF pairs. ECHOS sends only the
characters you specify. The only character you cannot put into an ECHOS
message is the NUL character (ASCII 0).
To include the command separator character [^] or the redirection and piping
symbols [<>|] in an ECHOS message, enclose them in quotes (see Argument
Quoting) or precede them with the escape character.
Trailing spaces in the message are normally ignored. To display trailing
spaces, enclose them in back-quotes, as in the example above.
ECHOS can not be used to change or display the current command-echo state.
Use ECHO to control echoing of commands in a batch file or at the prompt. |
|
|
DOS倒下了,但永远不死
DOS NEVER DIES !
投票调查:
http://www.cn-dos.net/forum/viewthread.php?tid=46187
本人尚未解决的疑难问题:
http://www.cn-dos.net/forum/viewthread.php?tid=15135
http://www.cn-dos.net/forum/viewthread.php?tid=47663
http://www.cn-dos.net/forum/viewthread.php?tid=48747 |
|
2008-9-19 12:43 |
|
|
hhasee
初级用户
积分 185
发帖 88
注册 2008-5-12
状态 离线
|
『第
8 楼』:
不是很明白,能不能加点注解????
|
|
2008-9-19 17:39 |
|
|
DOSforever
金牌会员
积分 4639
发帖 2239
注册 2005-1-30
状态 离线
|
|
2008-9-19 17:56 |
|
|
clong
初级用户
积分 121
发帖 54
注册 2008-1-10
状态 离线
|
『第
10 楼』:
可不可以换种思维?
set 2s=abc
echo 123%2s% >1.txt
提前转一步。
|
不懂就要虛心請教! |
|
2008-9-20 09:46 |
|
|
Climbing
铂金会员
网络独行侠
积分 6962
发帖 2753
注册 2003-4-16 来自 河北保定
状态 离线
|
『第
11 楼』:
一般来说,微软自己提供的echo命令,显示结果后面是紧跟着回车和换行的。所以,要实现楼主的需要,一般都要借助第三方工具,DosForever兄使用了4DOS,我印象中还有Horst的qecho(Quote echo),例如:
QECHO "something" CR LF
相当于: ECHO something
所以,以顶楼的情况来说,你可以使用:
qecho "123" >> 1.txt
qecho " ABC" CR LF >> 1.txt
d:\>qecho '123' >1.txt
d:\>qecho ' ABC' >> 1.txt
d:\>type 1.txt
123 ABC
|
偶只喜欢回答那些标题和描述都很清晰的帖子!
如想解决问题,请认真学习“这个帖子”和“这个帖子”并努力遵守,如果可能,请告诉更多的人!
|
|
2008-9-20 10:29 |
|
|
hhasee
初级用户
积分 185
发帖 88
注册 2008-5-12
状态 离线
|
『第
12 楼』:
都是高手啊,收获不小,十分感谢!!!
|
|
2008-9-26 10:09 |
|