![]() |
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-13 02:02 |
47,811 topics / 349,897 posts / today 0 new / 48,256 members |
| DOS学习入门 & 精彩文章 (教学室) » [Help] A question about using Echo in a batch file to create a file and write text? |
| Printable Version 1,876 / 7 |
| Floor1 hzy | Posted 2003-07-31 00:00 |
| 高级用户 Posts 135 Credits 578 | |
|
In a batch file, I want to create a test.bat under D:\, with the content: set aaa=bbb
So: ................ echo set aaa= >d:\test.bat echo bbb >>d:\test.bat But after executing the above statements, the content of d:\test.bat turns out to be: set aaa= bbb instead of: set aaa=bbb How can I make the strings output by the above two command lines go to the same line in d:\test.bat? |
|
| Floor2 电吉入侵 | Posted 2003-08-01 00:00 |
| 初级用户 Posts 377 Credits 1,480 | |
|
Actually, you already know how to do it yourself....
Wouldn't echo set aaa=bbb>d:\test.bat do it |
|
| Floor3 hzy | Posted 2003-08-01 00:00 |
| 高级用户 Posts 135 Credits 578 | |
|
The above example was just an analogy!
What I want to know is: how can I make the content output twice with the ECHO command be printed onto the same line in test.bat! |
|
| Floor4 lin1 | Posted 2003-08-02 00:00 |
| 初级用户 Posts 29 Credits 183 | |
|
That kind of idea won't work, ECHO absolutely outputs with a line break!
|
|
| Floor5 LanE | Posted 2003-08-02 00:00 |
| 银牌会员 Posts 648 Credits 1,835 | |
|
The ECHO command under DOS is too weak, not satisfying at all
|
|
| Floor6 Wengier | Posted 2003-08-02 00:00 |
| 系统支持 Posts 10,521 Credits 27,736 | |
The following is quoted from LanE's post at 2003-8-2 10:54:28: Then GNUish DOS commands (such as PRINTF, etc.) are also pretty good.. |
|
| Floor7 willsort | Posted 2003-09-29 00:00 |
| 元老会员 Posts 1,512 Credits 4,432 | |
|
Re hzy:
There are three ways of thinking about making them output on the same line: 1. Find a way not to output the carriage return: echo definitely won't work for this. You can try the GNUish commands the moderator mentioned; I personally use oecho.exe. If you can't find any of those, just write one yourself directly in C or assembly, it's simple anyway. Also, debug can write it too. If none of those methods suit your taste, then you can try the following idea. 2. Just use echo to output, then find a way to delete the carriage return: This is rather tricky. So far I've only seen using debug to reduce the file length by two bytes and then save it again, but this requires knowing the length of the source file in advance, so its use is somewhat limited. In addition, some editing software that supports pipe operations (such as edlin under dos5) or binary string replacement software (such as hexc in the undisk package) can also do this. echo r cx >delfeed.scr echo source file length minus 2, then convert it to hexadecimal >> delfeed.scr echo n sample2.tx>>delfeed.scr echo s >> delfeed.scr debug sample1.txt < delfeed.scr hexc sample1.txt sample2.txt 0d0a "" 3. Directly prepare the needed file in advance instead of outputting it temporarily. This method is suitable when the content of sample1.txt is fixed; using an editor to pre-edit the required header file without a carriage return is not very difficult. |
|
| Floor8 SHOCIAA | Posted 2003-10-01 00:00 |
| 中级用户 Posts 41 Credits 228 | |
The following is quoted from willsort's post at 2003-9-29 3:20:20: Still can't understand it |
|
|
[ Contact the Union admin team -
中国DOS联盟 -
Standard version ] Sponsored by ifanr Inc | © 2001–2023 |