<div dir="ltr">Duh -- forgot to mention it's for Solaris 11.2. head on Solaris is not GNU. OTOH, it has 'tac'! So I guess I'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"><<a href="mailto:gedetil@cs.umanitoba.ca" target="_blank">gedetil@cs.umanitoba.ca</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Sometimes, it'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't work with more "traditional" 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 <<a href="mailto:robert@keizer.ca" target="_blank">robert@keizer.ca</a><br></span><span class="">
<mailto:<a href="mailto:robert@keizer.ca" target="_blank">robert@keizer.ca</a>>> wrote:<br>
<br>
Idea from thread below:<br>
<br>
| awk '{if(a) print a;a=b;b=$0}'<br>
<br>
Note that you might want to include a little more logic if you want<br>
blanklines in there.. This doesn'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>
> Like Tim said, you first have to know how many lines exist in the file<br>
> before you can do anything other than stream processing.<br>
> On moderately-sized inputs, "wc -l" works reasonably well. On large<br>
> inputs, there's no way to do this efficiently unless you're willing to<br>
> sacrifice accuracy.<br>
><br>
> F=filename<br>
> L=$(wc -l $F)<br>
> head -n $(( $L - num_of_ignored_lines ))<br>
><br>
> -Adam<br>
><br>
> On March 4, 2015 2:36:24 PM CST, Kevin McGregor<br></span><span class="">
> <<a href="mailto:kevin.a.mcgregor@gmail.com" target="_blank">kevin.a.mcgregor@gmail.com</a> <mailto:<a href="mailto:kevin.a.mcgregor@gmail.com" target="_blank">kevin.a.mcgregor@<u></u>gmail.com</a>>> wrote:<br>
><br>
> Can someone help me out? I'm too tired to think straight.<br>
><br>
> Is there an easy/short way to get all BUT the last n lines of a<br>
> text file/input? All I can think of is reversing the input line<br>
> order and tail +n or something like that. FYI the input is not<br>
> very big.<br>
><br>
> Kevin<br>
</span></blockquote><span class="HOEnZb"><font color="#888888">
<br>
-- <br>
Gilbert E. Detillieux E-mail: <<a href="mailto:gedetil@muug.mb.ca" target="_blank">gedetil@muug.mb.ca</a>><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>