中国DOS联盟论坛

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-19 14:34
47,814 topics / 349,908 posts / today 0 new / 48,259 members
DOS疑难解答 & 问题讨论 (解答室) » [New Question] Output text to a specified line in pure DOS
Printable Version  3,156 / 15
Floor1 cocobi Posted 2008-09-12 13:32
初级用户 Posts 13 Credits 30
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 ]
Floor2 DOSforever Posted 2008-09-12 14:35
金牌会员 Posts 2,239 Credits 4,639
The strength lies in what you use. Take a look at the @line variable function of 4DOS.
Floor3 cocobi Posted 2008-09-12 15:35
初级用户 Posts 13 Credits 30
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"
Floor4 DOSforever Posted 2008-09-12 16:06
金牌会员 Posts 2,239 Credits 4,639
### 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 ]
Floor5 cocobi Posted 2008-09-12 16:46
初级用户 Posts 13 Credits 30

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
Floor6 DOSforever Posted 2008-09-12 17:06
金牌会员 Posts 2,239 Credits 4,639
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.
Floor7 cocobi Posted 2008-09-12 17:21
初级用户 Posts 13 Credits 30
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"
Floor8 DOSforever Posted 2008-09-12 17:34
金牌会员 Posts 2,239 Credits 4,639
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 ]
Floor9 cocobi Posted 2008-09-12 17:56
初级用户 Posts 13 Credits 30
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.
Floor10 DOSforever Posted 2008-09-12 18:06
金牌会员 Posts 2,239 Credits 4,639
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.
Floor11 cocobi Posted 2008-09-12 18:16
初级用户 Posts 13 Credits 30
Thank you for your patient answers and help. I took a look at the instructions for 4dos. It's very powerful. I'm learning.
Floor12 DOSforever Posted 2008-09-12 18:28
金牌会员 Posts 2,239 Credits 4,639
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.
Floor13 lianjiang2004 Posted 2008-09-12 18:51
金牌会员 Posts 1,884 Credits 3,946
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.
Floor14 DOSforever Posted 2008-09-12 19:26
金牌会员 Posts 2,239 Credits 4,639
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".
Floor15 lianjiang2004 Posted 2008-09-12 20:35
金牌会员 Posts 1,884 Credits 3,946
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.
1 2  Next
[ Contact the Union admin team - 中国DOS联盟 - Standard version ]
Sponsored by ifanr Inc | © 2001–2023