6

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

Update

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'
1

2 Answers 2

8

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.

4
  • @Giles So what will happen if tail -f -n 0 combination is used? Suppose that the file is growing continuously. Commented May 19, 2015 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. Commented May 19, 2015 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? Commented May 19, 2015 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. Commented May 19, 2015 at 10:42
2

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.

References:

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.