Computing.Net > Forums > Programming > Delete first line of text

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.

Delete first line of text

Reply to Message Icon

Name: copo24
Date: September 9, 2005 at 07:41:17 Pacific
OS: Win2k
CPU/Ram: 3.2G/1G
Comment:

Does anyone know how to delete the first line of text from a text file using a batch file (or a simple way from the command line)?

Thanks,
Cory



Sponsored Link
Ads by Google

Response Number 1
Name: Mechanix2Go
Date: September 10, 2005 at 00:23:11 Pacific
Reply:

Try this:

:: Nofirst.bat
:: skips first line

@echo off

if %1'==' echo which file? && goto :eof

:main
set NOTfirst=
for /f %%L in (%1) do call :NOfirst %%L
goto :eof

:NOfirst
if %NOTfirst%'==Y' echo %1
set NOTfirst=Y
goto :eof

:eof
:: done


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

M2


0

Response Number 2
Name: Mechanix2Go
Date: September 10, 2005 at 08:50:00 Pacific
Reply:

ooops,

Not quite.

That code will only put out the first "token" [word].

This is better:

:: skip1.bat
:: skips first line

@echo off

if %1'==' echo which file? && goto :eof

:main
set NOTfirst=
for /f "tokens=*" %%L in (%1) do call :NOfirst %%L
goto :eof

:NOfirst
if %NOTfirst%'==Y' echo %*
set NOTfirst=Y
goto :eof

:eof
:: done

NOTE: if there are redirect chars in the file [< > >>|] it will trip up this batch.


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

M2


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: Delete first line of text

Delete First Line of Text www.computing.net/answers/programming/delete-first-line-of-text/13940.html

.bat delete first line of text file www.computing.net/answers/programming/bat-delete-first-line-of-text-file/13773.html

Extract First Line of Text www.computing.net/answers/programming/extract-first-line-of-text/13939.html