<div dir="ltr">Duh -- forgot to mention it&#39;s for Solaris 11.2. head on Solaris is not GNU. OTOH, it has &#39;tac&#39;! So I guess I&#39;ll use that with tail +n (or something like that).<div><br></div><div>Thanks, guys!</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Mar 4, 2015 at 4:19 PM, Gilbert E. Detillieux <span dir="ltr">&lt;<a href="mailto:gedetil@cs.umanitoba.ca" target="_blank">gedetil@cs.umanitoba.ca</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Sometimes, it&#39;s the simple solutions that elude us...  :)<br>
<br>
But wait!  Compatibility alert!  Using a negative line count on head(1) is a GNU extension, and likely won&#39;t work with more &quot;traditional&quot; UNIX implementations.<br>
<br>
Gilbert<span class=""><br>
<br>
On 04/03/2015 4:10 PM, John Lange wrote:<br>
</span><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">
man head<br>
<br>
head --lines=-5 textfile.txt<br>
<br>
all but the last 5 lines.<br>
<br>
<br>
On Wed, Mar 4, 2015 at 3:49 PM, Robert Keizer &lt;<a href="mailto:robert@keizer.ca" target="_blank">robert@keizer.ca</a><br></span><span class="">
&lt;mailto:<a href="mailto:robert@keizer.ca" target="_blank">robert@keizer.ca</a>&gt;&gt; wrote:<br>
<br>
    Idea from thread below:<br>
<br>
    | awk &#39;{if(a) print a;a=b;b=$0}&#39;<br>
<br>
    Note that you might want to include a little more logic if you want<br>
    blanklines in there..  This doesn&#39;t store all of it in a file or in ram.<br>
<br>
<br>
    <a href="http://askubuntu.com/questions/475694/awk-command-to-print-all-the-lines-except-the-last-three-lines" target="_blank">http://askubuntu.com/<u></u>questions/475694/awk-command-<u></u>to-print-all-the-lines-except-<u></u>the-last-three-lines</a><br>
<br>
    On 2015-03-04 3:33 PM, Adam Thompson wrote:<br>
    &gt; Like Tim said, you first have to know how many lines exist in the file<br>
    &gt; before you can do anything other than stream processing.<br>
    &gt; On moderately-sized inputs, &quot;wc -l&quot; works reasonably well. On large<br>
    &gt; inputs, there&#39;s no way to do this efficiently unless you&#39;re willing to<br>
    &gt; sacrifice accuracy.<br>
    &gt;<br>
    &gt; F=filename<br>
    &gt; L=$(wc -l $F)<br>
    &gt; head -n $(( $L - num_of_ignored_lines ))<br>
    &gt;<br>
    &gt; -Adam<br>
    &gt;<br>
    &gt; On March 4, 2015 2:36:24 PM CST, Kevin McGregor<br></span><span class="">
    &gt; &lt;<a href="mailto:kevin.a.mcgregor@gmail.com" target="_blank">kevin.a.mcgregor@gmail.com</a> &lt;mailto:<a href="mailto:kevin.a.mcgregor@gmail.com" target="_blank">kevin.a.mcgregor@<u></u>gmail.com</a>&gt;&gt; wrote:<br>
    &gt;<br>
    &gt;     Can someone help me out? I&#39;m too tired to think straight.<br>
    &gt;<br>
    &gt;     Is there an easy/short way to get all BUT the last n lines of a<br>
    &gt;     text file/input? All I can think of is reversing the input line<br>
    &gt;     order and tail +n or something like that. FYI the input is not<br>
    &gt;     very big.<br>
    &gt;<br>
    &gt;     Kevin<br>
</span></blockquote><span class="HOEnZb"><font color="#888888">
<br>
-- <br>
Gilbert E. Detillieux           E-mail: &lt;<a href="mailto:gedetil@muug.mb.ca" target="_blank">gedetil@muug.mb.ca</a>&gt;<br>
Manitoba UNIX User Group        Web:    <a href="http://www.muug.mb.ca/" target="_blank">http://www.muug.mb.ca/</a><br>
PO Box 130 St-Boniface          Phone:  <a href="tel:%28204%29474-8161" value="+12044748161" target="_blank">(204)474-8161</a><br>
Winnipeg MB CANADA  R2H 3B4     Fax:    <a href="tel:%28204%29474-7609" value="+12044747609" target="_blank">(204)474-7609</a></font></span><div class="HOEnZb"><div class="h5"><br>
______________________________<u></u>_________________<br>
Roundtable mailing list<br>
<a href="mailto:Roundtable@muug.mb.ca" target="_blank">Roundtable@muug.mb.ca</a><br>
<a href="http://www.muug.mb.ca/mailman/listinfo/roundtable" target="_blank">http://www.muug.mb.ca/mailman/<u></u>listinfo/roundtable</a><br>
</div></div></blockquote></div><br></div>