0

how to remove first line in a super huge text file (min lines: 65536), using CMD (without any installing)?

example input file:

line1
line2
line3
line4

output file after I run the CMD:

line2
line3
line4

I have tried

more +1 "input.txt" > "output.txt"

but the max limit line in text file is 65535.

thank you all in advanced.

ps: super newbie in coding scripting.

Janice
  • 1
  • Please read [this](https://stackoverflow.com/q/71841990), to get a better idea of how you may be able to do it using the built-in PowerShell, and any potential issues with those methodologies. – Compo Oct 21 '22 at 10:22

2 Answers2

0

It is not the most efficient way in CMD, but this should work in Powershell:

get-content input.txt | select -Skip 1 | set-content "output.txt"
Keivan
  • 1,300
  • 1
  • 16
  • 29
JhonnyG
  • 1
  • 3
  • I woud advise not to use this answer. JhonnyG, please take a look at the question and answers I linked in my [comment](https://stackoverflow.com/questions/74151805/how-to-remove-first-line-from-a-huge-text-file-windows-cmd#comment130920894_74151805), to see why. – Compo Oct 21 '22 at 10:47
0
SET "sourcedir=u:\your files"
SET "destdir=u:\your results"
SET "filename1=%sourcedir%\hugefile.txt"
SET "outfile=%destdir%\outfile.txt"

(
FOR /f "skip=1usebackqeol=|delims=" %%b IN ("%filename1%") DO ECHO %%b
)>"%outfile%"

FC "%filename1%" "%outfile%"

Some cautions:

empty lines will be ignored

I've used eol=| to set the end-of-line character to |. Any line containing | is deemed to terminate at |. The default end-of-line character is ;.

Worked for me with 150,000 lines of "normalish" text - not containing the more rarely-used symbols.

Magoo
  • 77,302
  • 8
  • 62
  • 84