In the documentation for logstash, they mention the command tail -0a

I have never heard of the -a flag and I can't find any information on google, tail --help or the man pages.

What is the difference between tail -0a foo.bar and tail foo.bar


After testing this further, I wonder if it is a typo. Neither command works on my mac.

[root@interactive adaptive]# tail -0a /var/log/messages
tail: option used in invalid context -- 0

[root@interactive adaptive]# tail -a0 /var/log/messages
tail: invalid option -- 'a'

tail -0 is a historical, deprecated way of writing tail -n 0, i.e. print the last 0 lines of the file. (So tail -0 doesn't produce any output.)

I don't know of any tail implementation that has a -a option. From context, it looks like -f was meant. tail -f makes tail keep the file open when it reaches the end, and keep watching forever in case some other program appends more data at the end of the file, and prints this appended data as it comes. So tail -0f starts at the current end of the file, and prints any data that is subsequently appended to the file.

  • @Giles So what will happen if tail -f -n 0 combination is used? Suppose that the file is growing continuously.
    – Geek
    May 19 '15 at 5:58
  • 1
    @Geek It starts at the current end of the file, and prints any data that is subsequently appended to the file. May 19 '15 at 9:33
  • @Giles one more follow up question. So if I had used tail -n 5 -f file then as the file grows it always shows the last 5 lines right? Then going by that analogy tail -n 0 -f file should never output anything at all even if the files grows after starting the tail command. What am I missing?
    – Geek
    May 19 '15 at 10:05
  • 1
    @Geek No. With tail -n 5 -f, first the last 5 lines are displayed, then everything that's appended to the file. tail is not a viewer that refreshes to show the last N lines of the file, it's a filter that removes the beginning of the file. Once it's printed something out, it can't take it back. May 19 '15 at 10:42

The -0 means 0 lines, in other words, don't print any existing stuff.

None of the tail man pages mention a -a option. Perhaps they meant -f or -F, which would print any new contents written after tail started.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.