Delete everything following line 100

Tool for Search and Replace across multiple files.
Post Reply
User avatar
nkormanik
Posts: 8
Joined: Sat May 27, 2017 12:35 pm

Delete everything following line 100

Post by nkormanik »

Say we have a standard text file containing 150 lines. We want to delete EVERYTHING after line 100. Including linefeeds/carriage returns.

Following the change, when we open the file in a text editor, and hit Ctrl-End to get to the bottom, we end up at line 100.

The last 50 lines have been totally removed.

How best to do this??

Thanks much!

Nicholas Kormanik
User avatar
DigitalVolcano
Site Admin
Posts: 1717
Joined: Thu Jun 09, 2011 10:04 am

Re: Delete everything following line 100

Post by DigitalVolcano »

You can blank the lines after 100 the following way:

Click on the 'Limit to lines' tab and set 'From line' to 101. Uncheck the 'To' option.

Then, Click on the Regular Expression tab and set:

Regex:
.*
Replace:
(leave this blank)

The only issue with this is that it leaves blank lines after 100 rather than removing the lines. You'll then need to remove them in another pass using a regular expression:

Change back to 'Read entire file' (not limit to lines)

RegEx:
\s*$
Replace
(leave this blank)

Make sure the 'dot matches newline' and 'multi line anchors' options are not checkmarked.
User avatar
nkormanik
Posts: 8
Joined: Sat May 27, 2017 12:35 pm

Re: Delete everything following line 100

Post by nkormanik »

Greatly appreciate your getting back to me and clearly explaining.

Very glad to know that it can be done. And how.

Nicholas Kormanik
Post Reply