Search code examples
shellunixtail

How to use tail -f recursively on a directory and its sub-directories?


I am trying to use tail utility in linux to monitor the logs present under nested directories. I tried using tail -f /var/log/**/* but this only go till direct child of log directory. It does not dig beyond one level. Basically I am trying to tail all the application logs in docker container and pass them to /proc/1/fd/1, so that they appear under docker logs.


Solution

  • You need to enable

     shopt -s globstar
    

    if it is disabled in your shell.

    With this setting enabled, Bash will recurse directories with **.

    This is not a feature of Docker or tail, it is a feature of your shell.