Anyone have an idea how to implement a Head or Tail function in pure DOS. Similar to what other scripting languages have?
I use gnu utils on windows...works outstanding. every unix command you could ever want...available to all your windows scripts
Here is the link
In pure DOS? I doubt it, MS DOS is getting very old now
If you meant the Windows CMD shell then something like this:
::Tail.cmd::::::: @Echo OFF SETLOCAL :: Print the last n lines of a file to STDOUT :: :: tail [File] [n] :: :: n = Number of lines to print, default=10 Set tmpFile=%temp%\~tail.txt Set _lines_wanted=%2 If [%_lines_wanted%]== SET /A _lines_wanted=10 FindStr /r .* %1 >%tmpFile% For /F "tokens=1 delims=:" %%G in ('findstr /nr ".*" %tmpFile%') Do (Set _num_lines=%%G) Set /A skip=_num_lines-_lines_wanted If /I %skip% LEQ 0 Set skip=0 MORE /E +%skip% %tmpFile% Del %tmpFile%
If you have the resource kit there is a TAIL.exe included