|
Answer» Hi, I try to look for a way to look only for the first lines of a file. Is it can be done using type or is there is another command? TNX can't remember who, but someone says this can do it. Code: [Select]set /p var=< filename You could DOWNLOAD one of the many DOS/WIN equivalents to the Unix HEAD command or you could save this batch file somewhere on your path
If you call it htype.bat the usage would be htype "filename.txt" N where N is the NUMBER of lines you want to see. Use quotes if the filename contains spaces. Use CALL if from a batch file.
Code: [Select]@echo off setlocal enabledelayedexpansion set /a lin=1 set /a MAX=%2 for /f "delims=" %%L in (%1) do ( echo %%L set /a lin+=1 if !lin! GTR %max% goto end ) :end Quote from: contrex on June 26, 2007, 04:23:42 AM You could download one of the many DOS/WIN equivalents to the Unix HEAD command or you could save this batch file somewhere on your path
If you call it htype.bat the usage would be htype "filename.txt" N where N is the number of lines you want to see. Use quotes if the filename contains spaces. Use CALL if from a batch file.
Code: [Select]@echo off setlocal enabledelayedexpansion set /a lin=1 set /a max=%2 for /f "delims=" %%L in (%1) do ( echo %%L set /a lin+=1 if !lin! GTR %max% goto end ) :end
Tanks, it WORK beautiful, it as been a great help
|