Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to delete the first line of a file using Batch?

How to delete the first line of a file using Batch?

I really need help... I've tried everything but it didn't work. :( I've tried this :

@echo off
Type test.txt | findstr /I /V /C:"So, lets remove this line" >>Test2.txt
exit
like image 554
Login Avatar asked Feb 14 '23 22:02

Login


1 Answers

Some tasks are clumsy with pure batch techniques (and mangles characters) - this is a robust solution and uses a helper batch file called findrepl.bat that uses built in jscript-ing from - http://www.dostips.com/forum/viewtopic.php?f=3&t=4697

Place findrepl.bat in the same folder as the batch file.

type "file.txt"|findrepl /v /o:1:1 >"newfile.txt"

Another method is to use more.exe but it has limitations with the number of lines at 64K and it mangles TAB characters.

more +2 <file.txt >newfile.txt
like image 73
foxidrive Avatar answered Mar 10 '23 21:03

foxidrive