![]() |
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-25 23:08 |
47,812 topics / 349,910 posts / today 0 new / 48,264 members |
| DOS批处理 & 脚本技术(批处理室) » How to overwrite the content of a specified paragraph of a text with other text content |
| Printable Version 2,739 / 11 |
| Floor1 synn2006 | Posted 2006-10-28 03:00 |
| 新手上路 Posts 5 Credits 12 | |
|
──────────────── Moderation Record ──────────────── Performed by: namejm Original title: txt text content processing problem Modified title: How to overwrite the content of a specified paragraph in a text with other text content Description: Because the original title was too vague, it was not convenient for forum search and management. Three days after this notice was posted, the original poster had not changed the title, so I forcibly changed the title and deducted 2 points from the original poster. ──────────────── Moderation Record ──────────────── There are two files, a.txt and b.txt (the content is purely fictional, but it is enough to express my meaning): The content of a.txt is as follows: : monday : yang li wang yu shan liang : meeting study The content of b.txt is as follows: zhou zhuo tian li shang xiao nan sun chao Can a bat be used to achieve the following function: Each time first delete all the names after : in a.txt, and then add the name content in b.txt to it, so that it becomes as follows: a.txt: : monday : zhou zhuo tian li shang xiao nan sun chao : meeting study The content in b may always change in the future, I just want to execute the bat, and import them all after name in a.txt. If the bat cannot achieve this operation, can you tell me how to write it in vbs? In addition, there is another question, how to start and execute a vbs in a batch file? Looking forward to everyone's answers, thanks in advance!!!!!!!!!!!!!!!!!!!!! [ Last edited by namejm on 2007-1-25 at 01:00 PM ] |
|
| Floor2 无奈何 | Posted 2006-10-28 04:34 |
| 荣誉版主 Posts 356 Credits 1,338 | |
|
Try this command, it's a bit long written in one line.
Sed download address: http://www.student.northpark.edu/pemente/sed/gsed407x.zip |
|
| Floor3 不得不爱 | Posted 2006-10-28 04:45 |
| 超级版主 Posts 2,044 Credits 5,310 From 四川南充 | |
|
The meaning of "sed: -e expression #1, char 2: Unterminated address regex" is: In the sed command, in the first expression, at the 2nd character position, there is an unclosed address regular expression.
|
|
| Floor4 lxmxn | Posted 2006-10-28 04:55 |
| 版主 Posts 4,938 Credits 11,386 | |
|
This is an error message from the sed command. It's a syntax error, right? |
|
| Floor5 不得不爱 | Posted 2006-10-28 04:55 |
| 超级版主 Posts 2,044 Credits 5,310 From 四川南充 | |
|
The function of the SED command is quite good
|
|
| Floor6 不得不爱 | Posted 2006-10-28 04:56 |
| 超级版主 Posts 2,044 Credits 5,310 From 四川南充 | |
|
I got it by typing SED/?
|
|
| Floor7 无奈何 | Posted 2006-10-28 04:57 |
| 荣誉版主 Posts 356 Credits 1,338 | |
|
Re qwe1234567
This is an error message. Dude, try with a higher version and download the link on the second floor. |
|
| Floor8 lxmxn | Posted 2006-10-28 05:00 |
| 版主 Posts 4,938 Credits 11,386 | |
|
To view the help, you need to type like this: "sed -h" |
|
| Floor9 无奈何 | Posted 2006-10-28 05:16 |
| 荣誉版主 Posts 356 Credits 1,338 | |
|
A while ago there were several posts, but I didn't see your previous replies. Oh my, I thought it was an error message from running the old version. But indeed, there is a problem with the old version sed 302, and a small change is needed.
sed -e "/\:/,/\:/{/^ */d;}" -e "/\:/rb.txt" a.txt |
|
| Floor10 redtek | Posted 2006-10-28 05:17 |
| 金牌会员 Posts 1,147 Credits 2,902 | |
|
This is too powerful, admire it~:)
|
|
| Floor11 namejm | Posted 2006-10-28 05:50 |
| 荣誉版主 Posts 1,737 Credits 5,226 From 成都 | |
|
If you have to use batch processing to solve it, you can try the following code (if the number of lines in a.txt is extremely large, the speed will be relatively slow):
[ Last edited by namejm on 2007-1-25 at 12:54 PM ] |
|
| Floor12 synn2006 | Posted 2006-10-29 23:07 |
| 新手上路 Posts 5 Credits 12 | |
|
Thank you everyone for your help, I understand now~~~
|
|
|
[ Contact the Union admin team -
中国DOS联盟 -
Standard version ] Sponsored by ifanr Inc | © 2001–2023 |