gawk "{print $1>\"first.txt\";print $NF>\"last.txt\"}" a.txt
@echo off&setlocal
for /f "delims=" %%a in (a.txt) do (
for %%b in (%%a) do (
if not defined batch (echo\%%b>>first.txt & set batch=cn-dos) else (set word=%%b)
)
set batch=
if defined word call echo\%%word%%>>last.txt
)
@echo off& setlocal enabledelayedexpansion
for /f "tokens=1*" %%a in (a.txt) do (
echo\%%a>>first.txt
for %%c in (%%b) do set last=%%c
echo\!last!>>last.txt
)