<html><head></head><body>Like Tim said, you first have to know how many lines exist in the file before you can do anything other than stream processing.<br>
On moderately-sized inputs, &quot;wc -l&quot; works reasonably well.  On large inputs, there&#39;s no way to do this efficiently unless you&#39;re willing to sacrifice accuracy.<br>
<br>
F=filename<br>
L=$(wc -l $F)<br>
head -n $(( $L - num_of_ignored_lines ))<br>
<br>
-Adam<br><br><div class="gmail_quote">On March 4, 2015 2:36:24 PM CST, Kevin McGregor &lt;kevin.a.mcgregor@gmail.com&gt; wrote:<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<div dir="ltr">Can someone help me out? I&#39;m too tired to think straight.<div><br /></div><div>Is there an easy/short way to get all BUT the last n lines of a text file/input? All I can think of is reversing the input line order and tail +n or something like that. FYI the input is not very big.</div><div><br /></div><div>Kevin</div></div>
<p style="margin-top: 2.5em; margin-bottom: 1em; border-bottom: 1px solid #000"></p><pre class="k9mail"><hr /><br />Roundtable mailing list<br />Roundtable@muug.mb.ca<br /><a href="http://www.muug.mb.ca/mailman/listinfo/roundtable">http://www.muug.mb.ca/mailman/listinfo/roundtable</a><br /></pre></blockquote></div><br>
-- <br>
Sent from my Android device with K-9 Mail. Please excuse my brevity.</body></html>