Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>This the complete script for remove last N line </p> <ul> <li>count the total line</li> <li>set Line = Line - N , remain just processing lines number </li> </ul> <pre><code>@echo OFF setlocal EnableDelayedExpansion set LINES=0 for /f "delims==" %%I in (infile.txt) do ( set /a LINES=LINES+1 ) echo Total Lines : %LINES% echo. :: n = 5 , last 5 line will ignore set /a LINES=LINES-5 call:PrintFirstNLine > output.txt goto EOF :PrintFirstNLine set cur=0 for /f "delims==" %%I in (infile.txt) do ( echo %%I ::echo !cur! : %%I set /a cur=cur+1 if "!cur!"=="%LINES%" goto EOF ) :EOF exit /b </code></pre> <p>Here <code>call:PrintFirstNLine &gt; output.txt</code> will give the output in an external file name as <em>output.txt</em> </p> <p><strong>Output</strong> for sample Input </p> <pre><code>&lt;Project_Name&gt; &lt;CBA_Notifier&gt; &lt;Common&gt; &lt;File&gt;D:\CBA\CBA_Notifier\Project_Name\IPS-Util.jar&lt;/File&gt; &lt;File&gt;D:\CBA\CBA_Notifier\Project_Name\Notifier.bat&lt;/File&gt; &lt;File&gt;D:\CBA\CBA_Notifier\Project_Name\Notifier.xml&lt;/File&gt; &lt;File&gt;D:\CBA\CBA_Notifier\Project_Name\Notifier.jar&lt;/File&gt; &lt;/Common&gt; &lt;Project_Name&gt; &lt;File&gt;D:\CBA\CBA_Notifier\IPS-Util.bat&lt;/File&gt; </code></pre> <p></p> <p>remove last 5 line </p> <p><strong>Update</strong></p> <pre><code>:PrintFirstNLine set cur=0 for /F "tokens=1* delims=]" %%I in ('type "infile.txt" ^| find /V /N ""') do ( if "%%J"=="" (echo.) else ( echo.%%J set /a cur=cur+1 ) if "!cur!"=="%LINES%" goto EOF ) </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload