Page 1 of 1

Deleting last line in files

Posted: Sun Aug 19, 2007 1:37 am
by frankm
I'm sure this is easy but I can't figure out how to do it.

I want to use AFR to delete the last line of a few thousand text files but I don't know what regular expression to use to select the last line - the last lines don't necessarily end with line breaks.

Thanks

Re: Deleting last line in files

Posted: Sun Aug 19, 2007 7:18 pm
by Abacre
Go to main menu - Action - Options - Batch Replace
check "Modifier S"
check "Modifier G"

Go to Batch replace tab, check on "Use regular expressions".
Put into the grid, search for:
\A(.*)\r\n.*\r?\n?\Z

Replace with:
$1

That's all I verified it works perfectly.

Note: in this example we use line breaks used in Windows (\r\n)
Otherwise you should use search for: \A(.*)\n.*\n?\Z

Re: Deleting last line in files

Posted: Mon Aug 20, 2007 12:28 am
by frankm
Thank you Roman - that works great. :D

Re: Deleting last line in files

Posted: Sat Sep 22, 2007 6:14 am
by digitalmonkeyman
solution received


Thanks