user2172165
user2172165

Reputation: 107

Delete Last line from txt file by using Batch

I want to remove my last blank line of .txt file by using batch script. My last line will be always blank.

Upvotes: 3

Views: 14345

Answers (2)

Jim Ho
Jim Ho

Reputation: 2790

using sed:

sed '$d' in

$ indicates the last line and d means to delete the matched pattern.

Upvotes: 3

Magoo
Magoo

Reputation: 79983

If your output file has only one blank line and by a blank line you mean an empty line - containing no characters then as a batch-file command:

for /f "delims=" %%i in (sqloutfile.txt) do >>newfile.txt echo %%i

Or from the prompt,

for /f "delims=" %i in (sqloutfile.txt) do >>newfile.txt echo %i

Upvotes: 0

Related Questions