Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add "tail -n" functionality #123

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

AndriiChuzhynov
Copy link

Hi, here is my implementation of feature request #83
It adds 4 configuration options:

  1. LastLines - outputs the last NUM lines.
    It's done by finding the location of required line and changing tail.Config.Location according to found location.
    While seeking it stepping back by bytes defined by PageSize (4096 default). It's done to avoid reading the whole file.

  2. FromLine - the same as LastLines, but looking for the line from the start.

  3. PageSize - The optional option. Configures the buffer size for step. Might be reasonable to increase if the file is huge.

  4. SeekOnReOpen - By default if a file was reopened no line seek performed.
    If this option configured as True - reopened file will be read with the desired line.

If LastLines and FromLine both configured FromLine will be used and LastLines will be ignored.
If NUM of lines 0 or less nothing will happen.
It works with "follow" and without it as well.

I'll appreciate for any comments and suggestions.

@dinoba
Copy link

dinoba commented Aug 15, 2017

Hi,

any update about this?

@nishantroy
Copy link

Came to request this feature^ Any updates @AndriiChuzhynov ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants