-1

I have a log file recieveing msgs of up to 8k bytes. I would like those messages to be smaller. I am currently tailing the log file with tail -c +1 -F however this grabs the entire 8k message which is to big. I would like to do something like tail -c 2048 -F however I don't want to lose and text from the msgs. Will tail -c 1024 -F cause me to lose some of the msg if the msg is over 1024 bytes?

Additional Info: I am calling the tail command from python with and my regex filtering lags if the message is too large.

for line in sh.tail("-c", "4096", "-F", path, _iter=True):
    # Doing some regex filtering here
steve
  • 2,488
  • 5
  • 26
  • 39
  • What object has a `tail` method? – chepner Oct 03 '14 at 19:35
  • From what *we can see in you code*, you're not "calling the tail command from python", you're passing some parameters to some `tail` method of a `sh` object. – Alois Mahdal Oct 03 '14 at 21:20
  • `sh` is a package that allows one to call some system programs. Here are the docs: http://amoffat.github.io/sh/# – steve Oct 03 '14 at 21:35

1 Answers1

-1

tail -n +2 prints everything from second line to the end. What you are looking for is rather tail -n 2 or shorter: tail -2 which will take the last two lines.

The same schema applies to bytes:

As man tail says:

-c, --bytes=K output the last K bytes; alternatively, use -c +K to output bytes starting with the Kth of each file

RTFM?

m.wasowski
  • 6,329
  • 1
  • 23
  • 30
  • my docs on my unix system are not the same as yours, and appear to not be as descriptive. – steve Oct 03 '14 at 21:38
  • http://www.gnu.org/software/coreutils/manual/coreutils.html#tail-invocation && http://linux.die.net/man/1/tail And next time please specify what unix flavour you are using, there are subtle differences between, for example, gnu/linux and solaris – m.wasowski Oct 03 '14 at 21:49