sed or awk under XP in batch file (DOS box) - print $1 lines then delete $1 lines from a file

John Bartley K7AAY <[email protected]>
Newsgroups gmane.comp.gnu.utils
Organization http://groups.google.com
Message-ID <8fe76357-5b35-4de1-96ff-6512a0cc8cfd@k13g2000hse.googlegroups.com>
I need to print $1 lines from a file, and then delete that number of
lines.
$1 has been derived in the prior line with
wc -l sourcefile.txt | awk '{$1 /= 4 ; $1 = int($1) ; print $1 }'

I've tried numerous awk and sed statements, a la:

sed -e -n "$1,p" sourcefile.txt > list.1
sed -i "$1d" sourcefile.txt

sed $1q list.txt > list.1 & sed -i $1d sourcefile.txt

awk "{(FNR < $1); print}" sourcefile.txt > list.1


Your help would be appreciated.  Thank you.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.