是否有用于cmd.exe的sed類實用程序?我希望使用windows命令行以編程方式編輯文件內容(cmd.exe)。在*nix中SED完成這些任務。窗戶里有等效的東西嗎?
3 回答
眼眸繁星
TA貢獻1873條經驗 獲得超9個贊
今天Powershell救了我。
為grep有:
get-content?somefile.txt?|?where?{?$_?-match?"expression"}而為了sed有:
get-content?somefile.txt?|?%{$_?-replace?"expression","replace"}
至尊寶的傳說
TA貢獻1789條經驗 獲得超10個贊
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.Closecscript replace.vbs "C:\One.txt" "Robert" "Rob"
- 3 回答
- 0 關注
- 925 瀏覽
添加回答
舉報
0/150
提交
取消
