本帖最后由 ipmitool 于 2017-6-26 07:58 编辑
請問要如何刪除txt關鍵字整行
比如抓到 txt 裡面有 8組 GPU UUID 就刪除 8筆 整行#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
#include <GuiImageList.au3>
#include <WindowsConstants.au3>
#include <Array.au3>
#include <File.au3>
#include <Excel.au3>
#include <MsgBoxConstants.au3>
#include <FileConstants.au3>
#include <Date.au3>
#include <GuiStatusBar.au3>
#include <Constants.au3>
#include <GUIConstantsEx.au3>
#include <FontConstants.au3>
#include <StaticConstants.au3>
#include <GuiConstants.au3>
$path=@ScriptDir
FileCopy("nvidia-smi-a.txt","nvidia-smi-a-backup.txt",$FC_OVERWRITE + $FC_CREATEPATH)
$List = _FileListToArray($path, "nvidia-smi-a-backup.txt")
For $element = 1 to $List[0] step 1
For $line = 1 to 3 Step 1
_FileWriteToLine ($List[$element], 2, "", 1)
Next
_ReplaceStringInFile ($List[$element], "XXX", _FileWriteToLine($List[$element],1,"",1), 0,1 )
_ReplaceStringInFile ($List[$element], "XXX", "XXX02", 0, 1 )
_ReplaceStringInFile ($List[$element], "XXX", "XXX03", 0, 1 )
_ReplaceStringInFile ($List[$element], " ", @CRLF, 0, 1 )
Next
;sleep(500)
|