简体   繁体   中英

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. 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.)

  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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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