China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --

Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!

中国DOS联盟论坛
The time now is 2026-07-31 23:34
中国DOS联盟论坛 » DOS学习入门 & 精彩文章 (教学室) » Ask the great experts, how many ways are there to generate text files (*.txt) using DOS commands? View 7,575 Replies 16
Original Poster Posted 2005-08-03 22:00 ·  中国 贵州 贵阳 电信
新手上路
Credits 6
Posts 4
Joined 2005-08-03 21:56
20-year member
UID 41314
Status Offline
Ask the great experts, how many ways are there to generate text files (*.txt) using DOS commands?
Floor 2 Posted 2005-08-03 22:11 ·  中国 山西 临汾 中移铁通
元老会员
★★★★
Batchinger
Credits 4,432
Posts 1,512
Joined 2002-10-18 00:00
23-year member
UID 19
Gender Male
Status Offline
Re sexgirl:

Please tell us the original intention or goal for which you need this knowledge, what the restrictions are, and other background information you think should be stated. Otherwise, it will be difficult for you to get the answer you want.
※ Batchinger 致 Bat Fans:请访问 批处理编程的异类 ,欢迎交流与共享批处理编程心得!
Floor 3 Posted 2005-08-03 22:32 ·  中国 贵州 贵阳 电信
新手上路
Credits 6
Posts 4
Joined 2005-08-03 21:56
20-year member
UID 41314
Status Offline
In the computer professional title examination questions, there is a question: "In the MS-DOS mode of Windows 98, generate a file from the keyboard. The content of the file is 'I`m a teacher', the file name is LX.TXT, and save it to drive A."
c:\1.jpg
Floor 4 Posted 2005-08-03 22:39 ·  中国 山西 大同 中移铁通
元老会员
★★★★
Batchinger
Credits 4,432
Posts 1,512
Joined 2002-10-18 00:00
23-year member
UID 19
Gender Male
Status Offline
Re sexgirl:

  Then you can use the following sentence pattern (using the echo command and the redirection output symbol ">"):

  echo I'm a teacher>A:\LX.TXT

  Or use this sentence pattern (using the copy command and the console device con):

  copy con A:\LX.txt
I'm a teacher(Press Ctrl+Z here, excluding the parentheses)
※ Batchinger 致 Bat Fans:请访问 批处理编程的异类 ,欢迎交流与共享批处理编程心得!
Floor 5 Posted 2005-08-03 22:53 ·  中国 贵州 贵阳 电信
新手上路
Credits 6
Posts 4
Joined 2005-08-03 21:56
20-year member
UID 41314
Status Offline
Grate不尽, the second method is the correct answer, I also want to figure out the specific meaning represented by Ctrl+Z
Floor 6 Posted 2005-08-03 22:58 ·  IANA 局域网IP(Private-Use)
钻石会员
★★★★★
Credits 10,051
Posts 3,040
Joined 2002-11-11 00:00
23-year member
UID 223
Gender Male
Status Offline
Ctrl +Z indicates the end of the file. Pressing F6 can also do it. Check it with a hex editor.
简单就是美
Floor 7 Posted 2005-08-03 23:03 ·  中国 贵州 贵阳 电信
新手上路
Credits 6
Posts 4
Joined 2005-08-03 21:56
20-year member
UID 41314
Status Offline
Thank you very much. I just learned today that DOS is so profound. Once again, I show my respect to the expert!
Floor 8 Posted 2005-08-03 23:35 ·  中国 广东 广州 白云区 电信
金牌会员
★★★★
D◎$ Fαп
Credits 4,562
Posts 1,883
Joined 2004-01-19 00:00
22-year member
UID 15812
Gender Male
From 广东广州
Status Offline
I clearly remember that this question was discussed last year, and that computer exam question was exactly the same.
----====≡≡≡≡ 我的至爱,永远是MSDOS!≡≡≡≡====----
Floor 9 Posted 2005-08-06 20:42 ·  中国 山西 大同 中移铁通
元老会员
★★★★
Batchinger
Credits 4,432
Posts 1,512
Joined 2002-10-18 00:00
23-year member
UID 19
Gender Male
Status Offline
Re sexgirl:

For your question, I really can't figure out why echo + redirection is not the correct answer? Unless it requires that there are no carriage returns and line feeds in the file, but it doesn't have such a restriction.

For this question, in fact, there are more methods, such as:

type con > a:\lx.txt
I'm a teacher (press Ctrl+Z here, excluding the parentheses)

Or:

debug a:\lx.txt
e 100 "I'm a teacher"
r cx
d
w
q

There is also the edlin solution, and it doesn't limit the use of third-party tools, so there are countless optional answers. In fact, since I have a little understanding of DOS, I have found that the so-called "standard answers" in many computer DOS test questions have historical limitations and application limitations.
※ Batchinger 致 Bat Fans:请访问 批处理编程的异类 ,欢迎交流与共享批处理编程心得!
Floor 10 Posted 2005-08-06 21:59 ·  中国 广东 广州 电信
金牌会员
★★★★
D◎$ Fαп
Credits 4,562
Posts 1,883
Joined 2004-01-19 00:00
22-year member
UID 15812
Gender Male
From 广东广州
Status Offline
Re: re-sort:

Hehe, the so-called "correct answer" is actually just the reference answer from that computer textbook. There's no need to get overly nitpicky. Nowadays, many computer certification exam textbooks (level one or two) have relatively simple questions related to DOS, so the answers aren't too profound. The method of using copy con is a very common practice, which is easy for computer beginners to accept. I actually think the method of using echo redirection belongs to the field of batch processing programming. Computer level one, two, etc. exams usually don't involve the application of batch processing, and the method of using debug is rarely used even by experts.

[ Last edited by JonePeng on 2005-8-6 at 22:00 ]
----====≡≡≡≡ 我的至爱,永远是MSDOS!≡≡≡≡====----
Floor 11 Posted 2005-08-08 11:52 ·  中国 山西 运城 中移铁通
元老会员
★★★★
Batchinger
Credits 4,432
Posts 1,512
Joined 2002-10-18 00:00
23-year member
UID 19
Gender Male
Status Offline
Re JonePeng:

  What I mean is that we can break out of the constraints of exam questions, use divergent thinking, and make the topic "How many ways are there to generate text files with DOS commands" by the original poster more worthy of its name.

  Regarding copy con, it may not be more common than type con >. As for whether it is easy to accept, it also depends on the degree of acceptance and how many people can know both the reason and the result. For example, what does con mean? What does it represent? Why is it not a file but can be copied? Why does Ctrl+Z represent the end of a file?

  Regarding echo, in fact, I use it in the command line much more frequently than copy con, because its input volume is smaller. And debug is also often used in some fields. Because they each have their own advantages and disadvantages, studying them better can prevent us from being at a loss when we need them.

  In fact, there are quite a lot of methods to generate text files. I will give the scheme of pipeline commands again:


find "" /v < con > filename
text
(^Z)

more < con > filename
text
(^Z)

sort < con > filename
text
(^Z)

echo text|find "" /v > filename

echo text|more > filename

echo text|sort > filename

echo text|sort|find "" /v > filename

echo text|find "" /v|sort > filename

echo text|sort|more|find "" /v > filename

.....
※ Batchinger 致 Bat Fans:请访问 批处理编程的异类 ,欢迎交流与共享批处理编程心得!
Floor 12 Posted 2005-08-08 14:35 ·  中国 广东 广州 白云区 电信
金牌会员
★★★★
D◎$ Fαп
Credits 4,562
Posts 1,883
Joined 2004-01-19 00:00
22-year member
UID 15812
Gender Male
From 广东广州
Status Offline
Really didn't expect there are so many ways! Great!!!
----====≡≡≡≡ 我的至爱,永远是MSDOS!≡≡≡≡====----
Floor 13 Posted 2009-06-21 03:27 ·  中国 广东 深圳 罗湖区 电信
新手上路
Credits 8
Posts 6
Joined 2009-06-08 07:05
17-year member
UID 146938
Gender Male
From 深圳市
Status Offline
Learning hard! When will I reach your level?
Floor 14 Posted 2009-06-21 07:08 ·  中国 山东 联通
初级用户
Credits 25
Posts 12
Joined 2007-08-30 18:36
18-year member
UID 96210
Gender Male
Status Offline
To be honest, I use ">" more than anything else. echo is indeed very commonly used. However, copy con... is only used in some programming, and the frequency is far lower than that of echo & >. These damn computer exam questions should be more accurate. Don't not understand whether it's right or wrong, and just use a single answer to evaluate.
Floor 15 Posted 2009-06-21 08:24 ·  墨西哥
新手上路
Credits 10
Posts 6
Joined 2009-06-20 11:04
17-year member
UID 147798
Gender Male
Status Offline
So many methods originally,!!!
Forum Jump: