|
HAT
版主
       
积分 9023
发帖 5017
注册 2007-5-31
状态 离线
|
|
2008-7-14 16:27 |
|
|
26933062
银牌会员
    
积分 2268
发帖 879
注册 2006-12-19
状态 离线
|
『第 32 楼』:
使用 LLM 解释/回答一下
31 楼思路也是先把a.txt拼接成一行,再替换。
测试同样不行,刚下了个change 试了试,
问一个问题: 在change 中怎么表示不包括某字符的行?
The idea of building block 31 is also to concatenate a.txt into one line first and then replace. The test is still not working. I just downloaded a change and tried it.
Ask a question: How to represent lines that do not include a certain character in change?
|

致精致简! |
|
2008-7-14 17:21 |
|
|
qzwqzw
银牌会员
     天的白色影子
积分 2343
发帖 636
注册 2004-3-6
状态 离线
|
『第 33 楼』:
使用 LLM 解释/回答一下
看样子没什么问题嘛,如何不行?
change不是sed
没有那么多的正则标记
至于不包含指定字符的行
是有一个/v的开关
类似find
Last edited by qzwqzw on 2008-7-14 at 05:41 PM ]
It seems there's no problem. How come it doesn't work?
change is not sed
There aren't so many regular expression markers
As for the lines that don't contain the specified character
There is a /v switch
Similar to find
Last edited by qzwqzw on 2008-7-14 at 05:41 PM ]
|
|
2008-7-14 17:34 |
|
|
qzwqzw
银牌会员
     天的白色影子
积分 2343
发帖 636
注册 2004-3-6
状态 离线
|
『第 34 楼』:
使用 LLM 解释/回答一下
哦,明白了
你没有注意到change是for dos的程序吗?
在win32 console cmd下运行要先初始化中文环境的
chcp 437>nul & graftabl 936>nul
Oh, I see.
Didn't you notice that change is a program for DOS?
To run it under the win32 console cmd, you need to initialize the Chinese environment first.
chcp 437>nul & graftabl 936>nul
|
|
2008-7-14 17:39 |
|
|
26933062
银牌会员
    
积分 2268
发帖 879
注册 2006-12-19
状态 离线
|
『第 35 楼』:
使用 LLM 解释/回答一下
Originally posted by qzwqzw at 2008-7-14 17:39:
哦,明白了
你没有注意到change是for dos的程序吗?
在win32 console cmd下运行要先初始化中文环境的
chcp 437>nul & graftabl 936>nul
确实是这个问题,谢谢!
不过我还是想问一下 在change 中怎么表示不包括某字符的行?
我的思路是 先将所有句号都替换成回车、再删除所有不包含句号的行的回车
Originally posted by qzwqzw at 2008-7-14 17:39:
Oh, I understand.
Did you not notice that change is a program for DOS?
To run it under the win32 console cmd, you need to initialize the Chinese environment first.
chcp 437>nul & graftabl 936>nul
It is indeed this problem, thank you!
But I still want to ask, how to represent the lines that do not include a certain character in change?
My idea is to first replace all periods with carriage returns, and then delete the carriage returns of all lines that do not contain periods
|

致精致简! |
|
2008-7-14 17:44 |
|
|
26933062
银牌会员
    
积分 2268
发帖 879
注册 2006-12-19
状态 离线
|
『第 36 楼』:
使用 LLM 解释/回答一下
哪里有 change。exe 的教程吗? 帮助信息是英文的我一个都看懂啊!。。。
Is there a tutorial for change.exe? The help information is in English and I can't understand any of it...
|

致精致简! |
|
2008-7-14 17:59 |
|
|
HAT
版主
       
积分 9023
发帖 5017
注册 2007-5-31
状态 离线
|
『第 37 楼』:
使用 LLM 解释/回答一下
我这里有一部分中文帮助,不全。
CHANGE.EXE 是一个以命令行方式处理对文件的修改工具,目标文件可以是任意大小任意格式。可以一次执行30条命令!非常地高效。
一、基本格式:
change 源文件.txt /from “被替换的串” /to “替换串” /in “条件”
二、已知限制是它不支持长名,可能不认识一些windows下的特殊字符作文件名。对此,解决之道是以短文件名访问(例如:myfile~1.txt)。
三、详细功能列表:
⒈處理的文件不限大小,前提是磁盤上至少要有与目标文件等大的预留空间,用于临时存放其副本;
⒉不仅处理文本文件,也处理二进制文件;
⒊替入和换出的字符串长度可以不同;
⒋可以指定替换行为只在特定行发生,特定行的标志是有另一个指定的字符(串)出现,这个字符串还允许大小写敏感;
⒌可以同时执行多达30个修改指令;
⒍支持子目录;
⒎兼容dos/Unix/Mac 文本格式;
⒏输入输出字符串可以是文本的(Ascii),也可以是十六进制值或十进制值;
⒐替换速的特快;
⒑具有备份选项,以防源文件可能损坏;
⒒替换工作可以交互式进行(控制台);
⒓除命令行、控制台它还允许把多条指令组合编制为一个控制文件一次执行;
⒔可以使用布尔变量;
⒕源文件名支持通配符;
⒖"*"用在指定的被修改字符串时,表示由当前位置到行尾的整个子串;
⒗在指定目标字符串时,可以设定“列”,仅当字符位于此范围内时才发生替换;
⒘可以按文件属性排除某个文件不被处理;
⒙可以排除某些行不处理;
⒚按ESC可以中止处理进程。
⒛
四、如何指定参数
当程序运行时,它将以如下三种方式读取参数:
⒈INI文件
⒉系统环境变量
⒊命令行
先看最常用的命令行语法。
To/From/In规范:
FROM 被替换的文字
TO 用于替换的文字
TO (可选)指定发生替换行为的特定行标志
举例,设test.txt文件包含如下两行:
The quick brown fox jumped over
the lazy brown dog.
我们输入:
change /from brown /to red /fox
则文件变为:
The quick red fox jumped over
the lazy brown dog.
即:有出现"fox"的那行"brown:被替换为"red",其它行不变。
如果所指定字符串包含空格或其他特殊字符,请用双引号,比如:
CHANGE test.TXT /FROM "my music" /TO "my video"
或者用十六进制字符处理特殊字符,如:
CHANGE test.TXT /FROM &H0D0A0D0A /TO &H0D0A
(删除多余的行)
设定列宽的例子:
change test.txt /from ok 5/10 /to no
只替换从第5列到第10列的ok 为 no,这个功能是按首字符认定位置的,比如有一个“ok”位于4,5列那么它不会被替换。
仅删除的例子:
change test.txt /from no /to null
(即:删除所有的no)
如果要忽略英文字母的大小写,使用参数 /I
与DOS类似,可以用参数 /s 处理所有子目录中文件的替换工作
替换指定行的例子:
change test.txt /from no /to re /lines 3-8 30-50
(即:只替换3到8行和30到50行的字符)
出于安全目的,该程序总要自动生成一个临时文件备份源文件,如果用 /N文件名 参数另指定一个输出文件,则没有临时文件输出。
要消除文件末尾多余的空格,可以用参数 /trim
使用布尔变量的例子:
CHANGE TEST.TXT /FROM Apple /TO Banana /IN (red OR brown) AND NOT Pear
将替换apple为banana,但所在行必须有red或brown出现,并且没有Pear出现
本程序的返回误码意义:
0 无错,有修改
1 无错,无修改
253 提前中止
254 内部错误
255 语法错
I have a part of Chinese help, incomplete.
CHANGE.EXE is a command-line tool for processing file modifications. The target file can be of any size and any format. It can execute 30 commands at a time! Very efficient.
I. Basic format:
change source file.txt /from "string to be replaced" /to "replacement string" /in "condition"
II. The known limitation is that it does not support long names and may not recognize some special characters in Windows as file names. The solution is to access with the short file name (for example: myfile~1.txt).
III. Detailed function list:
1. The processed file is not limited in size, provided that there is at least the same amount of reserved space on the disk as the target file for temporarily storing its copy;
2. It can handle not only text files but also binary files;
3. The lengths of the substituted and replaced strings can be different;
4. The replacement behavior can be specified to occur only in specific lines. The mark of the specific line is that another specified character (string) appears. This string also allows case sensitivity;
5. Up to 30 modification instructions can be executed simultaneously;
6. Supports subdirectories;
7. Compatible with dos/Unix/Mac text formats;
8. The input and output strings can be text (Ascii), or hexadecimal values or decimal values;
9. The replacement speed is extremely fast;
10. Has a backup option in case the source file may be damaged;
11. The replacement work can be carried out interactively (console);
12. In addition to the command line and console, it also allows combining multiple instructions into a control file for execution at one time;
13. Boolean variables can be used;
14. The source file name supports wildcards;
15. "*" when specified in the string to be modified means the entire substring from the current position to the end of the line;
16. When specifying the target string, the "column" can be set, and the replacement will only occur when the character is within this range;
17. Files can be excluded from processing according to file attributes;
18. Some lines can be excluded from processing;
19. Pressing ESC can abort the processing process.
20.
IV. How to specify parameters
When the program runs, it will read parameters in the following three ways:
1. INI file
2. System environment variables
3. Command line
First look at the most commonly used command line syntax.
To/From/In specification:
FROM text to be replaced
TO text for replacement
TO (optional) specify the specific line mark where the replacement behavior occurs
For example, suppose the test.txt file contains the following two lines:
The quick brown fox jumped over
the lazy brown dog.
We enter:
change /from brown /to red /fox
Then the file becomes:
The quick red fox jumped over
the lazy brown dog.
That is: the "brown" in the line where "fox" appears is replaced with "red", and other lines remain unchanged.
If the specified string contains spaces or other special characters, use double quotes, for example:
CHANGE test.TXT /FROM "my music" /TO "my video"
Or use hexadecimal characters to handle special characters, such as:
CHANGE test.TXT /FROM &H0D0A0D0A /TO &H0D0A
(Delete redundant lines)
Example of setting column width:
change test.txt /from ok 5/10 /to no
Only replace ok from column 5 to column 10 with no. This function recognizes the position according to the first character. For example, if there is an "ok" in columns 4 and 5, it will not be replaced.
Example of only deleting:
change test.txt /from no /to null
(That is: delete all no)
If you want to ignore the case of English letters, use the parameter /I
Similar to DOS, you can use the parameter /s to handle the replacement work of files in all subdirectories
Example of replacing specified lines:
change test.txt /from no /to re /lines 3-8 30-50
(That is: only replace the characters in lines 3 to 8 and 30 to 50)
For security purposes, the program always automatically generates a temporary file to back up the source file. If another output file is specified with the /N file name parameter, there will be no temporary file output.
To eliminate extra spaces at the end of the file, use the parameter /trim
Example of using Boolean variables:
CHANGE TEST.TXT /FROM Apple /TO Banana /IN (red OR brown) AND NOT Pear
Will replace apple with banana, but the line must have red or brown appear, and Pear does not appear
The meaning of the return error code of this program:
0 No error, modified
1 No error, no modification
253 Aborted in advance
254 Internal error
255 Syntax error
|

 |
|
2008-7-14 18:04 |
|
|
HAT
版主
       
积分 9023
发帖 5017
注册 2007-5-31
状态 离线
|
『第 38 楼』:
使用 LLM 解释/回答一下
//不过我还是想问一下 在change 中怎么表示不包括某字符的行?
/V says to find those items that do NOT match the specification;
//But I still want to ask, how to represent the lines that do not include a certain character in change?
/V says to find those items that do NOT match the specification;
|

 |
|
2008-7-14 18:05 |
|
|
26933062
银牌会员
    
积分 2268
发帖 879
注册 2006-12-19
状态 离线
|
『第 39 楼』:
使用 LLM 解释/回答一下
谢谢我得到的中文帮助信息也是这些,讲的太少了。
change a.txt /from "&H0D0A" /to "yyy&H0D0A" /in 。
我的本意是将包含句号的行的回车替换为yyy加回车,但是怎么没有句号的行末尾也加上了yyy ???
Thanks, the Chinese help information I got is also like this, too little.
change a.txt /from "&H0D0A" /to "yyy&H0D0A" /in 。
My original intention was to replace the carriage return of the line containing the full stop with yyy plus carriage return, but why did the lines without full stops also add yyy at the end???
|

致精致简! |
|
2008-7-14 18:14 |
|
|
qzwqzw
银牌会员
     天的白色影子
积分 2343
发帖 636
注册 2004-3-6
状态 离线
|
『第 40 楼』:
使用 LLM 解释/回答一下
确实是这个问题,谢谢!
不过我还是想问一下 在change 中怎么表示不包括某字符的行?
我的思路是 先将所有句号都替换成回车、再删除所有不包含句号的行的回车
--------------------
真是较真的厉害
既然已经有了合适的方案
何必要舍易求难?
change有两种工作模式
一种是binary(block)模式
也就是我提到全文文本替换
按块读取字节然后进行替换
对0d0a视同普通字节
另一种是text(record)模式
也就是我说过的行缓冲模式
按行读取文本然后进行替换
对0d0a会作特殊处理
而如果/from /to /in中使用&H十六进制表示的字符
则直接进入binary模式
而/in开关则需要text模式的支持
所以你的替换操作是无效的
下面的命令是个示例
change \test\a.txt /n\test\b.txt /from "文件" /to "file" /in not "File"
Indeed, that's the problem. Thanks!
But I still want to ask, how to represent lines that do not include a certain character in change?
My idea is to first replace all periods with carriage returns, and then delete the carriage returns of all lines that do not contain periods.
--------------------
Really very meticulous
Since there is already a suitable solution
Why go for the difficult instead of the easy?
Change has two working modes
One is binary (block) mode
That is, the full-text replacement I mentioned
Read bytes in blocks and then perform replacement
Treat 0d0a as ordinary bytes
The other is text (record) mode
That is, the line buffering mode I mentioned
Read text by line and then perform replacement
Special processing will be done for 0d0a
And if &H hexadecimal characters are used in /from /to /in
Then it directly enters binary mode
And the /in switch requires the support of text mode
So your replacement operation is invalid
The following command is an example
change \test\a.txt /n\test\b.txt /from "文件" /to "file" /in not "File"
|
|
2008-7-14 19:10 |
|
|
26933062
银牌会员
    
积分 2268
发帖 879
注册 2006-12-19
状态 离线
|
『第 41 楼』:
使用 LLM 解释/回答一下
多谢多谢,又有不少收获。。。。 ^_^
Thanks, thanks a lot, got quite a few gains again... ^_^
|

致精致简! |
|
2008-7-14 19:17 |
|
|
HAT
版主
       
积分 9023
发帖 5017
注册 2007-5-31
状态 离线
|
『第 42 楼』:
使用 LLM 解释/回答一下
qzwqzw 的讲解真是详细啊^_^
The explanation of qzwqzw is really detailed ah ^_^
|

 |
|
2008-7-14 19:34 |
|
|
26933062
银牌会员
    
积分 2268
发帖 879
注册 2006-12-19
状态 离线
|
『第 43 楼』:
使用 LLM 解释/回答一下
真是郁闷,qzwqzw 兄的示列代码我这么运行不了?
我测试代码如下: xp sp2
:
@echo off
chcp 437>nul & graftabl 936>nul
change \test\a.txt /n \test\c.txt /from "一" /to " yyy " /in not "。"
对这段代码的理解为:
运行test模式、即按行读取。不产生临时文件,新文件在c.txt 中,
替换不含句号的行中的“一”为 “ yyy ”
怎么就是运行不了呢?
It's really frustrating. Why can't I run brother qzwqzw's sample code?
My test code is as follows: xp sp2
:
@echo off
chcp 437>nul & graftabl 936>nul
change \test\a.txt /n \test\c.txt /from "一" /to " yyy " /in not "。"
The understanding of this code is:
Run in test mode, that is, read line by line. No temporary file is generated, the new file is in c.txt,
Replace "一" with " yyy " in the lines that do not contain full stops
|

致精致简! |
|
2008-7-14 23:25 |
|
|
qzwqzw
银牌会员
     天的白色影子
积分 2343
发帖 636
注册 2004-3-6
状态 离线
|
『第 44 楼』:
使用 LLM 解释/回答一下
晕!
test是我自己的示例文本文件的相对路径
并非模式
/n后不要跟空格
Oh!
test is the relative path of my own sample text file
not a pattern
Do not put spaces after /n
|
|
2008-7-15 00:16 |
|
|
26933062
银牌会员
    
积分 2268
发帖 879
注册 2006-12-19
状态 离线
|
『第 45 楼』:
使用 LLM 解释/回答一下
看来它是定要欺负我了,我也这样测试过,还是不行
@echo off
cd.>d\c.txt
chcp 437>nul & graftabl 936>nul
change \d\a.txt /n\d\c.txt /from "一" /to " yyy " /in not "。"
Last edited by 26933062 on 2008-7-15 at 01:35 PM ]
It seems it's determined to bully me. I've tested like this too, still no good
@echo off
cd.>d\c.txt
chcp 437>nul & graftabl 936>nul
change \d\a.txt /n\d\c.txt /from "一" /to " yyy " /in not "。"
Last edited by 26933062 on 2008-7-15 at 01:35 PM ]
|

致精致简! |
|
2008-7-15 13:34 |
|