help-gnu-utils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


From: John Bartley K7AAY
Subject: sed or awk under XP in batch file (DOS box) - print $1 lines then delete $1 lines from a file
Date: Thu, 1 May 2008 13:17:09 -0700 (PDT)
User-agent: G2/1.0

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.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]