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-02 21:21
中国DOS联盟论坛 » DOS疑难解答 & 问题讨论 (解答室) » [New Question] Output text to a specified line in pure DOS View 2,859 Replies 15
Original Poster Posted 2008-09-12 13:32 ·  中国 广东 广州 番禺区 电信
初级用户
Credits 30
Posts 13
Joined 2005-10-11 00:37
20-year member
UID 43336
Status Offline
How to output the specified line of a text document under pure DOS. Or read the specified line as a parameter. Or similar functions.
The function of the pure DOS for command is still too weak.

[ Last edited by cocobi on 2008-9-22 at 10:04 PM ]
Floor 2 Posted 2008-09-12 14:35 ·  中国 上海 电信
金牌会员
★★★★
Credits 4,639
Posts 2,239
Joined 2005-01-30 00:00
21-year member
UID 35785
Gender Male
Status Offline
The strength lies in what you use. Take a look at the @line variable function of 4DOS.
Floor 3 Posted 2008-09-12 15:35 ·  中国 广东 广州 番禺区 电信
初级用户
Credits 30
Posts 13
Joined 2005-10-11 00:37
20-year member
UID 43336
Status Offline
Pure DOS's for doesn't support the /f parameter.
@line? Can you give an example? The foundation is really not good.
I ask this mainly to implement deleting temporary files in the Windows user directory under DOS.
The idea is like this. List the folders under docume~1 (the folder name is the user name) and output to a file.
dir %windrv%\docume~1\ /b /ad >winuser.lst
Then read this winuser.lst line by line and set the read content as a custom variable winuser*
Then execute
deltree "%windrv%\docume~1\%winuser1%\Local Settings\temp"
deltree "%windrv%\docume~1\%winuser1%\Local Settings\tempor~1"
Floor 4 Posted 2008-09-12 16:06 ·  中国 上海 电信
金牌会员
★★★★
Credits 4,639
Posts 2,239
Joined 2005-01-30 00:00
21-year member
UID 35785
Gender Male
Status Offline
### 4DOS 帮助主题:@LINE

@LINE:返回指定文件的第 n 行。文件中的第一行编号为 0。对于超出文件末尾的所有行号,返回 "**EOF**"。

@LINE 在处理每行不超过 511 个字符的文件时有效;较长的行将无法准确计数。

@LINE 函数必须读取文件的每一行以找到你请求的行,因此如果在长循环或大文件中使用会导致明显延迟。要更有效地按顺序处理文件的每一行,可使用 FOR 命令,或 @FILEOPEN 和一系列 @FILEREADs。

如果指定 CON 作为文件名,可从标准输入获取输入。如果使用此功能将输入重定向到 @LINE,必须使用命令分组,否则重定向无法正常工作(管道到 @LINE 无需命令分组;此限制仅适用于输入重定向)。例如:

(echo %@line) < myfile.dat

windrv 是什么环境变量?你自己定义的?

根据你要达成的目的,可以使用 for,当然是在 4DOS 下的 for

for /a:d/h %f in (%windrv%\docume~1\*.*) deltree "%f\locals~1\temp"

[ Last edited by DOSforever on 2008-9-12 at 04:09 PM ]
Floor 5 Posted 2008-09-12 16:46 ·  中国 广东 广州 番禺区 电信
初级用户
Credits 30
Posts 13
Joined 2005-10-11 00:37
20-year member
UID 43336
Status Offline

for /a:d/h %f in (%windrv%\docume~1\*.*) deltree "%f\locals~1\temp"

This is powerful.
I took a look at the latest version of 4dos 7.5? Unfortunately, it's an exe for win9x
According to the following statement, it seems that only a 4dos.com is needed

You can use 4DOS to replace the DOS built-in COMMAND.COM. In CONFIG.SYS, use
shell=C:\4DOS\4DOS.COM @C:\4DOS\4DOS.INI /P,
In AutoExec.Bat, add
SET COMSPEC=C:\4DOS\4DOS.COM @C:\4DOS\4DOS.INI /P

Just change the path according to the situation, right?
ps: Please help upload a 4dos.com. Thanks
Floor 6 Posted 2008-09-12 17:06 ·  中国 上海 电信
金牌会员
★★★★
Credits 4,639
Posts 2,239
Joined 2005-01-30 00:00
21-year member
UID 35785
Gender Male
Status Offline
http://cn-dos.net/forum/viewthread.php?tid=20079

The path in config.sys can be written as you like, and the line in autoexec.bat can be omitted.
Floor 7 Posted 2008-09-12 17:21 ·  中国 广东 广州 番禺区 电信
初级用户
Credits 30
Posts 13
Joined 2005-10-11 00:37
20-year member
UID 43336
Status Offline
It is indeed possible to extract 4dos.com, which is quite large, over 250k+.
Is it certain that only the 4dos.com file is needed? What's the use of the OPTION.EXE file? Can it be omitted?
In addition, when writing a batch script, the parameter for 4dos.com's for should probably be %%var.
The original line for /a:d/h %f in (%windrv%\docume~1\*.*) deltree "%f\locals~1\temp" should be changed to for /a:d/h %%f in (%windrv%\docume~1\*) deltree /y "%%f\locals~1\temp"
Floor 8 Posted 2008-09-12 17:34 ·  中国 上海 电信
金牌会员
★★★★
Credits 4,639
Posts 2,239
Joined 2005-01-30 00:00
21-year member
UID 35785
Gender Male
Status Offline
OPTION.EXE is used to set the initialization file 4DOS.INI for 4DOS, but the GUI looks more convenient. You can also modify 4DOS.INI manually.

If you don't need help, you only need the two files 4DOS.COM and 4DOS.INI. If you need to use the keystack internal command, you also need the file KSTACK.COM and it should be TSR in advance.

In the batch of 4DOS, the requirement for %f in the for command is not very strict. Both %%f and %f are legal.

[ Last edited by DOSforever on 2008-9-12 at 05:47 PM ]
Floor 9 Posted 2008-09-12 17:56 ·  中国 广东 广州 番禺区 电信
初级用户
Credits 30
Posts 13
Joined 2005-10-11 00:37
20-year member
UID 43336
Status Offline
keystack? echo.| echo y| That's enough, right.
ps: The command line interface of the forum is very interesting. I'm trying to use it to browse and post replies.
Floor 10 Posted 2008-09-12 18:06 ·  中国 上海 电信
金牌会员
★★★★
Credits 4,639
Posts 2,239
Joined 2005-01-30 00:00
21-year member
UID 35785
Gender Male
Status Offline
Whether it is sufficient depends on your own usage. Since you have looked at keystack, I think you must understand whether all its functions can be solved by pipelines.
Floor 11 Posted 2008-09-12 18:16 ·  中国 广东 广州 番禺区 电信
初级用户
Credits 30
Posts 13
Joined 2005-10-11 00:37
20-year member
UID 43336
Status Offline
Thank you for your patient answers and help. I took a look at the instructions for 4dos. It's very powerful. I'm learning.
Floor 12 Posted 2008-09-12 18:28 ·  中国 上海 电信
金牌会员
★★★★
Credits 4,639
Posts 2,239
Joined 2005-01-30 00:00
21-year member
UID 35785
Gender Male
Status Offline
You're welcome. There are few people like you who can recognize treasures. Many people I offer it to don't even want it, and they would rather go around in circles and finally "finally" solve the problem. I think they are really tired!

In addition, I suggest you modify the title of the post. DOS is DOS, there is no such thing as pure or not. Either it is or it isn't. Just like there is no such thing as pure or not Windows, pure or not UNIX.
Floor 13 Posted 2008-09-12 18:51 ·  中国 安徽 马鞍山 联通
金牌会员
★★★★
Credits 3,946
Posts 1,884
Joined 2006-01-20 13:00
20-year member
UID 49283
Gender Male
Status Offline
Personal understanding, because many people also call cmd DOS, so writing pure DOS can at least prevent others from using cmd scripts to make a fuss, which can effectively avoid misunderstandings, heh heh.
Windows 一键还原
http://www.yjhy.com
Floor 14 Posted 2008-09-12 19:26 ·  中国 上海 电信
金牌会员
★★★★
Credits 4,639
Posts 2,239
Joined 2005-01-30 00:00
21-year member
UID 35785
Gender Male
Status Offline
Because of this, we should not follow the mistake and continue. Since you said it's a DOS issue, then I will only consider the DOS environment. Either you clearly state it's the Windows command line or CMD environment. We must correct those vague concepts instead of us accommodating and following them.

Moreover, the forum already has a dedicated section for discussing other command line environments and a batch processing section that mixes both (basically, the current batch processing section discusses batch processing under Windows). The section here clearly says "DOS Troubleshooting & Problem Discussion".
Floor 15 Posted 2008-09-12 20:35 ·  中国 安徽 马鞍山 联通
金牌会员
★★★★
Credits 3,946
Posts 1,884
Joined 2006-01-20 13:00
20-year member
UID 49283
Gender Male
Status Offline
Last time I encountered one, it was about handling things under DOS. Then someone wrote a cmd script. I said at that time that it didn't seem to be what the楼主 wanted, but it turned out I misunderstood. It turned out it was supposed to be cmd. Hehe. So emphasizing DOS is necessary because there are too many people who don't distinguish between the two. There's no way. Hehe.
Windows 一键还原
http://www.yjhy.com
Forum Jump: