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-09 03:35
中国DOS联盟论坛 » DOS学习入门 & 精彩文章 (教学室) » Puzzles about the echo command writing to files View 2,595 Replies 5
Original Poster Posted 2007-02-14 00:46 ·  中国 湖北 仙桃 电信
初级用户
Credits 20
Posts 9
Joined 2007-02-02 08:26
19-year member
UID 78405
Gender Male
Status Offline
In DOS, you can use the echo test>a.txt to create a text file named a.txt with the content test.

I want to ask, when using the echo command to write echo <%script %> >a.txt, it cannot be written to the file. What methods are there to solve this?

Also, in DOS, is there any way to modify a certain line of a file, just like vi?

Thank you everyone.
Floor 2 Posted 2007-02-14 02:08 ·  中国 上海 东方有线
中级用户
★★
Credits 218
Posts 86
Joined 2006-08-10 10:45
19-year member
UID 60205
Gender Male
Status Offline
echo ^<%script%^> >a.txt
This way you can successfully write the text
Floor 3 Posted 2007-02-14 04:22 ·  中国 湖北 仙桃 电信
初级用户
Credits 20
Posts 9
Joined 2007-02-02 08:26
19-year member
UID 78405
Gender Male
Status Offline
Floor 4 Posted 2009-11-25 16:46 ·  中国 河南 焦作 联通
新手上路
Credits 2
Posts 1
Joined 2009-11-11 01:54
16-year member
UID 154539
Gender Male
Status Offline
Floor 5 Posted 2009-12-16 23:37 ·  中国 北京 联通
初级用户
Credits 44
Posts 36
Joined 2009-03-17 11:36
17-year member
UID 141561
Gender Male
Status Offline
Echo hello world>filename can write the string 'hello world' into the file. Then you can run type filename, and you can see hello world displayed. Of course, you can also use the command echo nul>filename to clear the file without deleting it. Note: it's nul, not null @_@
Floor 6 Posted 2009-12-17 07:24 ·  中国 广东 东莞 电信
初级用户
Credits 29
Posts 17
Joined 2009-12-01 02:38
16-year member
UID 155707
Gender Male
Status Offline
Originally posted by vk at 2007-2-14 02:08:
echo ^<%script%^> >a.txt
This way you can successfully write the text.


Good use of escape characters!~
Forum Jump: