<br><br><div class="gmail_quote">On Wed, Sep 30, 2009 at 11:57 AM, Alex Beamish <span dir="ltr"><<a href="mailto:talexb@gmail.com">talexb@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div class="im">> So then, is there a more efficient/faster way of saying "Delete the first X<br>
> number of lines from file foo"?<br>
<br>
</div>I would expect you could fashion something workable like this <br>
<br>
# Get the number of lines in the file ..<br>
wc -l file<br>
<br>
# tail the desired number of lines to a new file ..<br>
tail -n $numberOfLinesInFile-$numberOfLinesYouDontWant file >newfile<br>
<br>
# and move the files around.<br>
rm file; mv newfile file<br></blockquote><div><br>If using shell script instead of Perl is an option, then sed is the best tool<br><br> ToDel=20<br> sed -i "1,${ToDel}d" file<br><br>will delete the first 20 lines from the file. <br>
<br>HTH<br><br>Antonio<br><br></div></div>