|
hhihh
新手上路

积分 12
发帖 4
注册 2006-5-13
状态 离线
|
『楼 主』:
如何将文本文件里面的符号替换成空格?
使用 LLM 解释/回答一下
谢谢了,用批处理的方式,文件见附件
内容是2006|2007|2008|2009
Thanks, using the batch processing method, the file is attached. The content is 2006|2007|2008|2009
附件
1: hhh.txt (2006-5-13 12:28, 19 bytes, 下载附件所需积分 1 点
,下载次数: 46)
|
|
2006-5-13 12:28 |
|
|
3742668
荣誉版主
      
积分 2013
发帖 718
注册 2006-2-18
状态 离线
|
『第 2 楼』:
使用 LLM 解释/回答一下
@echo off
set /p str=<hhh.txt
set str=%str:|= %
echo %str%
pause
只要把每一行的内容保存到变量中,再用set命令改造就行了。给出的例子只能操作文本文件的第一行,要想操作多行,可以用for命令,或者用vbs脚本的scripting.filesystemobjects对象和split函数。
```
@echo off
set /p str=<hhh.txt
set str=%str:|= %
echo %str%
pause
```
Just save the content of each line into a variable and then use the set command to transform it. The given example can only operate the first line of the text file. To operate multiple lines, you can use the for command, or use the scripting.filesystemobjects object and split function of the vbs script.
|
|
2006-5-13 12:36 |
|
|
hhihh
新手上路

积分 12
发帖 4
注册 2006-5-13
状态 离线
|
『第 3 楼』:
使用 LLM 解释/回答一下
谢谢版主的解答,请帮忙写一个能处理上千条纪录的程序好吗?
最好是那个用FOR命令的,能看懂,嘿嘿
不是我懒,我刚开始学习DOS命令,但是工作中用到的太多了
再次感谢版主了
Thanks to the moderator for the explanation. Could you please help write a program that can handle thousands of records?
It's best to use the FOR command, something that's easy to understand, heh.
It's not that I'm lazy, I just started learning DOS commands, but there are too many used in work.
Thanks to the moderator again.
|
|
2006-5-13 13:49 |
|
|
hhihh
新手上路

积分 12
发帖 4
注册 2006-5-13
状态 离线
|
『第 4 楼』:
使用 LLM 解释/回答一下
能把处理后的信息保存到原来的文件里面吗?
Can the processed information be saved back to the original file?
|
|
2006-5-13 14:01 |
|
|
3742668
荣誉版主
      
积分 2013
发帖 718
注册 2006-2-18
状态 离线
|
『第 5 楼』:
使用 LLM 解释/回答一下
可以参考 这个贴子里面的vbs脚本,可以实现你要求的功能。
只需要在弹出的对话框中输入 "|:= " 就可以了。
You can refer to the VBS script in (url=http://www.cn-dos.net/forum/viewthread.php?tid=20327), which can realize the function you need. Just enter "|:= " in the pop-up dialog box.
|
|
2006-5-13 14:17 |
|
|
hhihh
新手上路

积分 12
发帖 4
注册 2006-5-13
状态 离线
|
『第 6 楼』:
使用 LLM 解释/回答一下
Originally posted by 3742668 at 2006-5-13 14:17:
可以参考这个贴子里面的vbs脚本,可以实现你要求的功能。
只需要在弹出的对话框中输入 "|:= &qu ...
看了一下,非常好,谢谢了
Originally posted by 3742668 at 2006-5-13 14:17:
You can refer to the vbs script in this post, which can achieve the function you need.
Just enter "|:= &qu ... in the pop-up dialog box...
Got it, it's very good, thank you
|
|
2006-5-13 14:41 |
|
|
fan927
初级用户
 
积分 82
发帖 31
注册 2006-5-23
状态 离线
|
『第 7 楼』:
使用 LLM 解释/回答一下
用sed方便一些,
sed "s/a/b/g" t.txt \\将t.txt中所以的字符a替换为字符b.
find "o" t.txt|sed "s/tt/xx/g" \\将t.txt文件里面所以包含字符"o"的行中的"tt"字符替换为字符"xx"
sed是linux里的经典命令之一,现在被一些高人嫁接到dos下,和批处理结合功能非常强大,灵活.还有很多高级用法,可以参考linux教程里sed命令.和linux下用法基本相同.这个命令只有80多k,在网上可以搜的到.
Last edited by fan927 on 2006-5-25 at 15:26 ]
It is more convenient with sed,
sed "s/a/b/g" t.txt \\Replace all characters a with character b in t.txt.
find "o" t.txt|sed "s/tt/xx/g" \\Replace the "tt" characters with character "xx" in all lines containing character "o" in the t.txt file
sed is one of the classic commands in Linux. Now it has been grafted to DOS by some experts and combined with batch processing, which is very powerful and flexible. There are also many advanced usages, and you can refer to the sed command in Linux tutorials. It is basically the same as the usage under Linux. This command is only more than 80k and can be found on the Internet.
Last edited by fan927 on 2006-5-25 at 15:26 ]
|
|
2006-5-25 15:24 |
|
|
willsort
元老会员
         Batchinger
积分 4432
发帖 1512
注册 2002-10-18
状态 离线
|
『第 8 楼』:
使用 LLM 解释/回答一下
Re fan927:
"sed是linux里的经典命令之一,现在被一些高人嫁接到dos下"
sed的设计构思应该发源于Unix下的编辑器ed,是 Eric S. Raymond 在91年前后为GNU组织所设想的开源操作系统所编写的一个字符流编辑器,因为是开源程序,所以很快出现了各种平台下的移植版本,而Howard Helman在当年所改写的 HHSED 提供了Unix@SUN4和DOS@PC两个平台下的运行版本。而那时候Linux才刚刚诞生,后来伴随着POSIX标准和Linux实现的成熟,sed的GNU版本才应用到了Linux中。
Re fan927:
"sed is one of the classic commands in Linux, and now some experts have ported it to DOS."
The design concept of sed should originate from the editor ed under Unix. It was a character stream editor written by Eric S. Raymond for the open-source operating system envisioned by the GNU organization around 1991. Since it is an open-source program, various ported versions for different platforms quickly appeared. And Howard Helman rewrote HHSED at that time, providing running versions for the Unix@SUN4 and DOS@PC platforms. At that time, Linux had just been born. Later, with the maturity of the POSIX standard and the realization of Linux, the GNU version of sed was applied to Linux.
|

※ Batchinger 致 Bat Fans:请访问 批处理编程的异类 ,欢迎交流与共享批处理编程心得! |
|
2006-5-25 19:02 |
|
|
fan927
初级用户
 
积分 82
发帖 31
注册 2006-5-23
状态 离线
|
『第 9 楼』:
使用 LLM 解释/回答一下
Originally posted by willsort at 2006-5-25 19:02:
Re fan927:
"sed是linux里的经典命令之一,现在被一些高人嫁接到dos下"
sed的设计构思应该发源于Unix下的编辑器ed,是 Eric S. Raymond 在91幠...
涨见识了,多谢willsort版主.
不过不知道这么优秀的命令为什么dos下没有呢?我觉得它对文本中字符的操作完全可以用"随心所欲"来形容.这正是批处理缺乏的.
Originally posted by willsort at 2006-5-25 19:02:
Re fan927:
"sed is one of the classic commands in Linux, and now it has been grafted to DOS by some experts"
The design concept of sed should have originated from the editor ed under Unix. Eric S. Raymond was in 1991...
Learned something new, thank you, moderator willsort.
But I don't know why such an excellent command is not available in DOS? I think its operation on characters in text can be described as "completely at will". This is exactly what batch processing lacks.
|
|
2006-5-25 20:11 |
|
|
willsort
元老会员
         Batchinger
积分 4432
发帖 1512
注册 2002-10-18
状态 离线
|
『第 10 楼』:
使用 LLM 解释/回答一下
Re fan927:
请注意8楼的这句话:“而Howard Helman在当年所改写的 HHSED 提供了Unix@SUN4和DOS@PC两个平台下的运行版本”。也就是说,早在sed刚出现的91年就已经有DOS下的sed版本了,只不过因为它是遵循GPL的开源软件,所以只能作为第三方工具而存在,不可能被微软包含在它的MS-DOS/Windows发行包中。
另外,随着GNU sed发展的日益成熟,其DOS16和Win32平台的移植品越来越强大,所以它逐渐像微软的软件一样成为事实标准,而HHSED则渐渐悄无声息了,其原因一则缺乏维护,二则它本就是GNU sed的Mod。
Last edited by willsort on 2006-5-25 at 23:16 ]
Re fan927:
Please note the statement in floor 8: "And Howard Helman's HHSED rewritten back then provided running versions for two platforms: Unix@SUN4 and DOS@PC". That is to say, as early as 1991 when sed first appeared, there was already a version of sed for DOS. However, because it is an open-source software following the GPL, it can only exist as a third-party tool and cannot be included in Microsoft's MS-DOS/Windows distribution packages.
In addition, as GNU sed has become increasingly mature in development, its ported versions for DOS16 and Win32 platforms have become more and more powerful. So it has gradually become a de facto standard like Microsoft's software, while HHSED has gradually faded into obscurity. The reasons are, on one hand, the lack of maintenance, and on the other hand, it was originally a Mod of GNU sed.
Last edited by willsort on 2006-5-25 at 23:16 ]
|

※ Batchinger 致 Bat Fans:请访问 批处理编程的异类 ,欢迎交流与共享批处理编程心得! |
|
2006-5-25 23:05 |
|
|
mylovelyqq
初级用户
 
积分 170
发帖 25
注册 2004-11-11
状态 离线
|
『第 11 楼』:
使用 LLM 解释/回答一下
Originally posted by 3742668 at 2006-5-13 12:36 PM:
@echo off
set /p str=<hhh.txt
set str=%str:|= %
echo %str%
pause
只要把每一行的内容保存到变量中,再用set命令改造就行了。给出的例子只能操你...
set str=%str:|= %
这句是什么意思啊,实在是不懂
The meaning of `set str=%str:|= %` is: It is using the substitution function of the `set` command in batch processing. It replaces all occurrences of the `|` character in the `str` variable with a space character. So it is replacing each `|` in the content read from the `hhh.txt` file (and stored in the `str` variable) with a space.
|
|
2006-11-29 03:19 |
|
|
ccwan
金牌会员
     
积分 2725
发帖 1160
注册 2006-9-23 来自 河北廊坊
状态 离线
|
『第 12 楼』:
使用 LLM 解释/回答一下
Originally posted by mylovelyqq at 2006-11-29 03:19:
set str=%str:|= %
这句是什么意思啊,实在是不懂
替换变量”str“中的”|“为空格
Originally posted by mylovelyqq at 2006-11-29 03:19:
What does the sentence "set str=%str:|= %" mean? I really don't understand.
Replace the "|" in the variable "str" with a space
|

三人行,必有吾师焉。 学然后知不足,教然后知困,然后能自强也。 |
|
2006-11-29 03:24 |
|
|
mylovelyqq
初级用户
 
积分 170
发帖 25
注册 2004-11-11
状态 离线
|
『第 13 楼』:
使用 LLM 解释/回答一下
Originally posted by ccwan at 2006-11-29 03:24 AM:
替换变量”str“中的”|“为空格
我知道是这个功能,这是set 的什么用法呀,查帮助没说吧,你能帮我分析一下这句吗,谢了
Originally posted by ccwan at 2006-11-20 03:24 AM:
Replace the "|" in the variable "str" with a space
I know this is the function. What is the usage of this in set? I didn't see it in the help. Can you help me analyze this sentence? Thanks
|
|
2006-11-29 03:30 |
|
|
mylovelyqq
初级用户
 
积分 170
发帖 25
注册 2004-11-11
状态 离线
|
『第 14 楼』:
使用 LLM 解释/回答一下
ccwan,你别老是不说清楚就没音了呀,光一个结果,原因,过程,理由呢
ccwan, you don't always make it clear and then disappear. Just a result, but where are the reasons, processes, and explanations?
|
|
2006-11-29 03:35 |
|
|
ccwan
金牌会员
     
积分 2725
发帖 1160
注册 2006-9-23 来自 河北廊坊
状态 离线
|
『第 15 楼』:
使用 LLM 解释/回答一下
Originally posted by mylovelyqq at 2006-11-29 03:30:
我知道是这个功能,这是set 的什么用法呀,查帮助没说吧,你能帮我分析一下这句吗,谢了
帮助中有啊,在第三页。%PATH:str1=str2%
Originally posted by mylovelyqq at 2006-11-29 03:30:
I know it's this function, what is the usage of set here? I didn't see it in the help. Can you help me analyze this sentence? Thanks.
It's in the help, on the third page. %PATH:str1=str2%
|

三人行,必有吾师焉。 学然后知不足,教然后知困,然后能自强也。 |
|
2006-11-29 03:38 |
|