是否有用于cmd.exe的sed类实用程序?我希望使用windows命令行以编程方式编辑文件内容(cmd.exe)。在*nix中SED完成这些任务。窗户里有等效的东西吗?
3 回答
SMILET
TA贡献1796条经验 获得超4个赞
grep
get-content somefile.txt | where { $_ -match "expression"}
sed
get-content somefile.txt | %{$_ -replace "expression","replace"}
达令说
TA贡献1821条经验 获得超6个赞
Const ForReading = 1 Const ForWriting = 2 strFileName = Wscript.Arguments(0) strOldText = Wscript.Arguments(1) strNewText = Wscript.Arguments(2) Set objFSO = CreateObject("Scripting.FileSystemObject") Set objFile = objFSO.OpenTextFile(strFileName, ForReading) strText = objFile.ReadAll objFile.Close strNewText = Replace(strText, strOldText, strNewText) Set objFile = objFSO.OpenTextFile(strFileName, ForWriting) objFile.Write strNewText objFile.Close
cscript replace.vbs "C:\One.txt" "Robert" "Rob"
- 3 回答
- 0 关注
- 311 浏览
添加回答
举报
0/150
提交
取消