Computing.Net > Forums > Programming > Get last line with batch file

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Get last line with batch file

Reply to Message Icon

Name: DkFusion
Date: September 25, 2008 at 08:42:45 Pacific
OS: Windows XP
CPU/Ram: P4 / 512 MB
Comment:

Hi,
I was wondering if it is possible to get the last line of a text file and save it to a variable? I found a script that gets the first line, but I have been unable to write one of my own. I could write it in c++ or VB.NET but with my work environment that is not allowed, so I am stuck with batch files.

Any help would be appreciated



Sponsored Link
Ads by Google

Response Number 1
Name: Mechanix2Go
Date: September 25, 2008 at 09:11:05 Pacific
Reply:

@echo off
setLocal EnableDelayedExpansion

for /f "tokens=* delims= " %%a in (myfile) do (
set var=%%a
)
echo !var!


=====================================
If at first you don't succeed, you're about average.

M2


0

Response Number 2
Name: DkFusion
Date: September 25, 2008 at 10:41:51 Pacific
Reply:

Thank you!

You are a total Rock Star !


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Get last line with batch file

Deleting lines with batch files www.computing.net/answers/programming/deleting-lines-with-batch-files/13330.html

Delete blank lines with batch file? www.computing.net/answers/programming/delete-blank-lines-with-batch-file/13018.html

Get last line from a file www.computing.net/answers/programming/get-last-line-from-a-file/15026.html