# What does tail -f <directory name> do?

I mistakenly executed the following command in the terminal:

tail -f /logs/applications/logs*

I got the following output:

tail: file shrunk!
Error 0


I am not sure what exactly happened. I have not been keeping track on the number of files in the directory for quiet a while. Could someone please explain what exactly happened, and did I lose any files.

Edit:

I am not sure if it is coincidence or not, but after I executed the code, I counted the number of files in the directory, and it was 10!

First time the number 10 got me paranoid...

I am not sure what exactly happened.

What happened was that the file was rotated by an external application. This is usual. Utilities like logrotate rotate log files, i.e. the contents of the existing log file are moved to another file and the existing one is blanked out before an application starts writing to it again.

When tail determines that the size of the tracked file has reduced, then it prints the message you observed and continues tracking the file.

Quoting from tail invocation section of GNU coreutils manual:

No matter which method you use, if the tracked file is determined to have shrunk, tail prints a message saying the file has been truncated and resumes tracking the end of the file from the newly-determined endpoint.

No you did not lose any files as tail command only shows the end of the files.

Passing /logs/applications/logs* to tail is same as passing multiple files/folders (anything that matches /logs/applications/logs* pattern). As this pattern can be matches also by directories, in these cases tail will fail to work.