Page 1 of 1

How to remove lines of plain text format

Posted: 23 Jul 2014 06:23
by mdivk
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.

Re: How to remove lines of plain text format

Posted: 23 Jul 2014 06:28
by foxidrive
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"

Re: How to remove lines of plain text format

Posted: 23 Jul 2014 07:03
by mdivk
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.

Re: How to remove lines of plain text format

Posted: 23 Jul 2014 07:15
by foxidrive
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.