|
cocobi
初级用户
 
积分 30
发帖 13
注册 2005-10-11
状态 离线
|
『楼 主』:
[新问题]纯dos输出文本指定行
使用 LLM 解释/回答一下
纯dos下如何输出文本文档的指定行.或读取指定行作为参数.或类似功能.
纯dos的for命令的功能还是太弱了.
Last edited by cocobi on 2008-9-22 at 10:04 PM ]
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 ]
|
|
2008-9-12 13:32 |
|
|
DOSforever
金牌会员
     
积分 4639
发帖 2239
注册 2005-1-30
状态 离线
|
|
2008-9-12 14:35 |
|
|
cocobi
初级用户
 
积分 30
发帖 13
注册 2005-10-11
状态 离线
|
『第 3 楼』:
使用 LLM 解释/回答一下
纯dos下的for不支持 /f参数啊.
@line? 可以给个范例吗?基础不是一般的差的说
我问这个主要是想实现dos下删除win的用户目录下的临时文件.
思路是这样.列出docume~1下的文件夹(用户名作文件夹名)输出到一个文件.
dir %windrv%\docume~1\ /b /ad >winuser.lst
再通过逐行读取这个winuser.lst并把读取的内容设定为一个自定义变量winuser*
再执行
deltree "%windrv%\docume~1\%winuser1%\Local Settings\temp"
deltree "%windrv%\docume~1\%winuser1%\Local Settings\tempor~1"
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"
|
|
2008-9-12 15:35 |
|
|
DOSforever
金牌会员
     
积分 4639
发帖 2239
注册 2005-1-30
状态 离线
|
『第 4 楼』:
使用 LLM 解释/回答一下
以下给出 @line 的具体帮助,你可能不需要用到
4DOS Help Topic: @LINE
@LINE: Returns line n from the specified file. The first line
in the file is numbered 0. "**EOF**" is returned for all line numbers
beyond the end of the file.
@LINE works with files having lines of no more than 511 characters; longer
lines will not be counted accurately.
The @LINE function must read each line of the file to find the line you
request, and will therefore cause significant delays if used in a long loop
or on a large file. For a more effective method of processing each line of
a file in sequence use the FOR command, or @FILEOPEN and a sequence of
@FILEREADs.
You can retrieve input from standard input if you specify CON as the
filename. If you are redirecting input to @LINE using this feature, you
must use command grouping or the redirection will not work properly (you can
pipe to @LINE without a command group; this restriction applies only to
input redirection). For example:
(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 ]
### 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 ]
|

DOS倒下了,但永远不死
DOS NEVER DIES !
投票调查:
http://www.cn-dos.net/forum/viewthread.php?tid=46187
本人尚未解决的疑难问题:
http://www.cn-dos.net/forum/viewthread.php?tid=15135
http://www.cn-dos.net/forum/viewthread.php?tid=47663
http://www.cn-dos.net/forum/viewthread.php?tid=48747 |
|
2008-9-12 16:06 |
|
|
cocobi
初级用户
 
积分 30
发帖 13
注册 2005-10-11
状态 离线
|
『第 5 楼』:
使用 LLM 解释/回答一下
for /a:d/h %f in (%windrv%\docume~1\*.*) deltree "%f\locals~1\temp"
这个强悍.
看了下4dos 最新版7.5? 可惜是个exe for win9x
按照下面说法好像只要一个4dos.com就可以了
可以用4DOS来代替DOS自带的COMMAND.COM,在CONFIG.SYS里面用
shell=C:\4DOS\4DOS.COM @C:\4DOS\4DOS.INI /P,
在AutoExec.Bat里面加
SET COMSPEC=C:\4DOS\4DOS.COM @C:\4DOS\4DOS.INI /P
看情况改路径就可以对吗?
ps:帮忙上传一个4dos.com.谢谢
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
|
|
2008-9-12 16:46 |
|
|
DOSforever
金牌会员
     
积分 4639
发帖 2239
注册 2005-1-30
状态 离线
|
|
2008-9-12 17:06 |
|
|
cocobi
初级用户
 
积分 30
发帖 13
注册 2005-10-11
状态 离线
|
『第 7 楼』:
使用 LLM 解释/回答一下
确实可以解压得到4dos.com,好大250k+
确定只需要4dos.com这个文件就可以了吗?OPTION.EXE这个文件可以不要,有什么用没有?
另外批处理编写4dos.com的for的参数因该是%%var吧
for /a:d/h %f in (%windrv%\docume~1\*.*) deltree "%f\locals~1\temp"
应该是
for /a:d/h %%f in (%windrv%\docume~1\*) deltree /y "%%f\locals~1\temp"
吧
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"
|
|
2008-9-12 17:21 |
|
|
DOSforever
金牌会员
     
积分 4639
发帖 2239
注册 2005-1-30
状态 离线
|
|
2008-9-12 17:34 |
|
|
cocobi
初级用户
 
积分 30
发帖 13
注册 2005-10-11
状态 离线
|
『第 9 楼』:
8
使用 LLM 解释/回答一下
keystack? echo.| echo y| 够用了吧.
ps:论坛的命令行界面很有意思.正尝试用它浏览和回帖.
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.
|
|
2008-9-12 17:56 |
|
|
DOSforever
金牌会员
     
积分 4639
发帖 2239
注册 2005-1-30
状态 离线
|
|
2008-9-12 18:06 |
|
|
cocobi
初级用户
 
积分 30
发帖 13
注册 2005-10-11
状态 离线
|
『第 11 楼』:
使用 LLM 解释/回答一下
谢谢你耐心解答和帮助.看了下4dos的说明.好强大.学习中.
Thank you for your patient answers and help. I took a look at the instructions for 4dos. It's very powerful. I'm learning.
|
|
2008-9-12 18:16 |
|
|
DOSforever
金牌会员
     
积分 4639
发帖 2239
注册 2005-1-30
状态 离线
|
|
2008-9-12 18:28 |
|
|
lianjiang2004
金牌会员
     
积分 3946
发帖 1884
注册 2006-1-20
状态 离线
|
『第 13 楼』:
使用 LLM 解释/回答一下
个人理解, 因为很多人把cmd也叫dos,所以写成纯dos,至少不会有人再拿cmd脚本来说事了,可有效避免误解,呵呵。
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 |
|
2008-9-12 18:51 |
|
|
DOSforever
金牌会员
     
积分 4639
发帖 2239
注册 2005-1-30
状态 离线
|
『第 14 楼』:
使用 LLM 解释/回答一下
正因为如此,所以我们更不应该跟着将错就错。既然你说了是 DOS 问题,那我就只考虑 DOS 环境,要么你就明说是 Windows 命令行或 CMD 环境。一定要把他们这些含糊不清观念给纠正过来,而不是我们迁就着跟着他们跑。
况且,论坛已经有了专门讨论其它命令行环境的版块,和两者都混在一起的批处理版块(基本上,现在的批处理版块讨论的都是 Windows 下的批处理)。这里的版块明确说了是“DOS疑难解答 & 问题讨论”。
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".
|

DOS倒下了,但永远不死
DOS NEVER DIES !
投票调查:
http://www.cn-dos.net/forum/viewthread.php?tid=46187
本人尚未解决的疑难问题:
http://www.cn-dos.net/forum/viewthread.php?tid=15135
http://www.cn-dos.net/forum/viewthread.php?tid=47663
http://www.cn-dos.net/forum/viewthread.php?tid=48747 |
|
2008-9-12 19:26 |
|
|
lianjiang2004
金牌会员
     
积分 3946
发帖 1884
注册 2006-1-20
状态 离线
|
『第 15 楼』:
使用 LLM 解释/回答一下
上次就碰到一个,问dos下处理的,结果有人写了cmd的脚本,我当时还说,似乎不是楼主想要的,结果还是我理解错了,原来就是要cmd的,呵呵。
所以强调dos,是很有必要的,因为二者不分的人太多了,没办法。呵呵。
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 |
|
2008-9-12 20:35 |
|