[RndTbl] Easy script question?

Adam Thompson athompso at athompso.net
Wed Mar 4 15:33:57 CST 2015


Like Tim said, you first have to know how many lines exist in the file before you can do anything other than stream processing.
On moderately-sized inputs, "wc -l" works reasonably well.  On large inputs, there's no way to do this efficiently unless you're willing to sacrifice accuracy.

F=filename
L=$(wc -l $F)
head -n $(( $L - num_of_ignored_lines ))

-Adam

On March 4, 2015 2:36:24 PM CST, Kevin McGregor <kevin.a.mcgregor at gmail.com> wrote:
>Can someone help me out? I'm too tired to think straight.
>
>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.
>
>Kevin
>
>
>------------------------------------------------------------------------
>
>_______________________________________________
>Roundtable mailing list
>Roundtable at muug.mb.ca
>http://www.muug.mb.ca/mailman/listinfo/roundtable

-- 
Sent from my Android device with K-9 Mail. Please excuse my brevity.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.muug.mb.ca/pipermail/roundtable/attachments/20150304/2d6391a7/attachment.html>


More information about the Roundtable mailing list