个人感觉这种纯P困难,就用python写了个 用不了几行可以搞定。不过大文件没测试 没怎么考虑效率。- import shutil
-
- str1 = "错误"
- str2 = "AutoConfig"
- file = "123.txt"
- file2 = "d:\\456.txt"
- file3 = "d:\\789.txt"
-
- with open(file,encoding="utf-8") as f:
- last10 = "".join(list(f)[-10:])
-
- if str1 in last10 and str2 in last10:
- shutil.copy(file, file2)
- with open(file2,encoding="utf-8") as f:
- flst = list(f)
- last4th6chars = flst[-4][:6] #前6个是 "错误 201"
- with open(file3,"w",encoding="utf-8") as fw:
- for line in flst[-20:]:
- if last4th6chars in line: fw.write(line)
复制代码
|