Advertisement
npocmaka

firstLines.bat

Jul 18th, 2013
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Batch 0.87 KB | None | 0 0
  1. @echo off
  2. setlocal enableExtensions
  3.  
  4. rem ------ validate parameters ------
  5. for %%H in ("/h" "-h" "-help" "/help") do if /I "%~1" EQU "%%~H" goto :help
  6. if "%~2" EQU "" goto :help
  7. if not exist "%~1" echo file does not exist && exit /b 3
  8. set /a "lines=%~2"
  9. if not defined lines echo pass a number bigger than 0 for the lines to be shown&&exit /b 1
  10. if defined lines if %lines%0 equ 0 echo pass a number bigger than 0 for the lines to be shown&&exit /b 2
  11. rem ---------------------------------
  12.  
  13. ;break>"%temp%\empty"
  14. @@fc "%temp%\empty" "%~1" /lb  %lines% /t |more +4 | findstr /B /E /V "*****"
  15. ;del /q /f "%temp%\empty"
  16.  
  17. goto :eof
  18. endlocal
  19.  
  20. :help
  21. echo Displays first lines of a given file
  22. echo.
  23. echo %~n0 file lines
  24. echo.
  25. echo.
  26. echo  lines     Number of lines to display.Must be bigger than 0.
  27. echo  file      Specifies the file.
  28. ::
  29. :: by Vasil "npocmaka" Arnaudov
  30. ::
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement