[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
返回列表 发帖
  1. Text = readTextFile("1.txt")
  2. Text = reReplace(Text,"\|.*",vbCrLf)
  3. writeTextFile Text,"2.txt"
  4. Function readTextFile(Path)
  5. Dim fso,ts
  6. Set fso = CreateObject("Scripting.Filesystemobject")
  7. Set ts = fso.OpenTextFile(Path,1)
  8. readTextFile = ts.ReadAll
  9. ts.Close
  10. End Function
  11. Function writeTextFile(Text,Path)
  12. Dim fso,ts
  13. Set fso = CreateObject("Scripting.Filesystemobject")
  14. Set ts = fso.CreateTextFile(Path,True)
  15. ts.Write Text
  16. ts.Close
  17. End Function
  18. Function reReplace(string1,Pattern,string2)
  19. Set re = New RegExp
  20. re.Pattern = Pattern
  21. re.Global = True
  22. re.IgnoreCase = True
  23. re.MultiLine = True
  24. reReplace = re.Replace(string1,string2)
  25. End Function
复制代码
sed 更方便:
  1. @sed "s/|.*//" 1.txt >2.txt
复制代码
1

评分人数

TOP

返回列表