简体   繁体   English

在文本文件的最后一行之前添加文本

[英]add text before the last line in a text file

I need to add text before the last line in a text file in windows using command. 我需要使用命令在Windows中文本文件的最后一行之前添加文本。 Can any one please suggest a method? 有人可以建议一种方法吗?

Thanks in advance. 提前致谢。

You can do it in 5 simple steps, and you can use any language of your choice or according to your other requirements ( like c, c++, java etc.) 您可以通过5个简单的步骤完成此操作,并且可以使用您选择的任何语言或根据您的其他要求(例如c,c ++,java等)使用

  1. Read Complete File 读取完整文件
  2. Extract Last line by looking for last newline 通过查找最后一个换行符来提取最后一行
  3. Store Last Line and erase it from file 存储最后一行并从文件中删除
  4. Append New Text 追加新文字
  5. Append last line which you deleted previously. 附加上次删除的最后一行。

Don't forget to close your file. 不要忘记关闭文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM