silverwire #7213(2008/08/19 07:52 GMT) [ Batchfile ] Rating0/0=0.00
バッチです。カバレッジ稼ぎのようでちょっと恥ずかしいのですが、あまり処理を複雑に したくなかったので、標準入力からの入力や-fオプションは実装しませんでした。 e.g. C:\>tail 3 tail.bat set /a i-=%1 endlocal & more +%i% %p% goto :EOF 以下の参考サイトのものはもっと複雑で頭が下がります。
see: 【続々々】tailコマンドの作成
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
:: tail.bat @echo off setlocal set i=0 set p=%~fs2 echo %1|findstr /r "[^0-9]" >NUL 2>&1 if %ERRORLEVEL% equ 0 (call :usage & exit /b 1) if "%p%" equ "" (call :usage & exit /b 1) if not exist %p% (call :usage & exit /b 1) for /f %%i in ('find /c /v "" ^< %p%') do set i=%%i set /a i-=%1 endlocal & more +%i% %p% goto :EOF :usage setlocal echo %~n0 [LINE] [FILE] endlocal goto :EOF
Rating0/0=0.00-0+
[ reply ]
silverwire
#7213()
[
Batchfile
]
Rating0/0=0.00
バッチです。カバレッジ稼ぎのようでちょっと恥ずかしいのですが、あまり処理を複雑に したくなかったので、標準入力からの入力や-fオプションは実装しませんでした。 e.g. C:\>tail 3 tail.bat set /a i-=%1 endlocal & more +%i% %p% goto :EOF 以下の参考サイトのものはもっと複雑で頭が下がります。see: 【続々々】tailコマンドの作成
:: tail.bat @echo off setlocal set i=0 set p=%~fs2 echo %1|findstr /r "[^0-9]" >NUL 2>&1 if %ERRORLEVEL% equ 0 (call :usage & exit /b 1) if "%p%" equ "" (call :usage & exit /b 1) if not exist %p% (call :usage & exit /b 1) for /f %%i in ('find /c /v "" ^< %p%') do set i=%%i set /a i-=%1 endlocal & more +%i% %p% goto :EOF :usage setlocal echo %~n0 [LINE] [FILE] endlocal goto :EOFRating0/0=0.00-0+
[ reply ]