How to remove lines of plain text format

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
mdivk
Posts: 15
Joined: 12 Jul 2011 09:37

How to remove lines of plain text format

#1 Post by mdivk » 23 Jul 2014 06:23

Hello,

I am not sure if this is a doable thing in DOS, maybe using the debug command? I have text files to be chopped off the first two lines and hopefully the last three lines. The biggest challenging is the text's size, some are around 400M but some end up GB.

Thanks. Any clue is appreciated.

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: How to remove lines of plain text format

#2 Post by foxidrive » 23 Jul 2014 06:28

This uses a helper batch file called `findrepl.bat` (by aacini) - download from: https://www.dropbox.com/s/rfdldmcb6vwi9xc/findrepl.bat

Place `findrepl.bat` in the same folder as the batch file or on the path.


Code: Select all

findrepl /o:3:-4 <"file.txt" >"newfile.txt"

mdivk
Posts: 15
Joined: 12 Jul 2011 09:37

Re: How to remove lines of plain text format

#3 Post by mdivk » 23 Jul 2014 07:03

Thank you for your quick reply, the bat file looks so complicated to me and I am not sure if our security department will allow it.

BTW: the command seems to me is generating a new file, it would be best to simply chop off the first 2 lines on the original file, and, if possible, also chop off the last 2 lines.

Thank you.

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: How to remove lines of plain text format

#4 Post by foxidrive » 23 Jul 2014 07:15

mdivk wrote: to simply chop off the first 2 lines on the original file, and, if possible, also chop off the last 2 lines.


Your question said the first two and the last three lines.

The repl batch file is robust and quick - and there is no way to remove lines without writing a new file.
Batch scripts always create a new file, delete the old one and rename the new file with the old name.

Post Reply