tail command retry flag not working with wildcards?

I want to tail a bunch of unknown directories names containing a particular non-existant file, e.g.:

tail -F /tmp/*/app.log

However that does not work as intended with the wildcard: if I create a file with that path, tail won't start following unless I restart the command. On the other hand if I run:

tail -F /tmp/example/app.log

as soon as the file appears the command will output: tail: '/tmp/example/app.log' has appeared; following new file

I have tried the -f filename --retry combination instead of -F and the result is the same.

How can that be solved and are there any other ways to achieve the same goal?


/tmp/*/app.log will be expanded by the shell (BASH I presume). If there exist matches, then this will be expanded to those matches and then passed as arguments to tail

$ find /tmp/test -type f
/tmp/test/a/app.log                                                                                                                                                                                                                                
/tmp/test/b/app.log                  

$ echo /tmp/test/*/app.log                                                                                                                                                                                        
/tmp/test/a/app.log /tmp/test/b/app.log

So, in the above case, tail would be configured to follow specifically app.log in a and app.log in b. If, at the time it was started, app.log in b didn't exist, it would not be followed. If new directories or files are created, it will also not follow them.

In the case of no matches, the unexpanded string will be passed as an argument to tail

$ echo /tmp/test/*/app2.log                                                                                                                                                                                     
/tmp/test/*/app2.log               

So, it will attempt to follow the literal pathname/filename /tmp/test/*/app2.log, which will probably never exist (or if it does exist, it's been created in a very odd way because having * as a directory name is not something I would advise doing under normal circumstances).