Forrest logo
back to the tail tool

system:log:follow:multiple

The command 'tail -f' is used to continuously monitor logs and display any new changes.
$ tail -f ${path_to_main_directory}/**/*.log
try on your machine

This command is used to continuously monitor and display the content of all the log files within a specific directory and its subdirectories.

Here is a breakdown of the command:

  • tail: It is a command-line tool used to display the last part of a file or continuously monitor file updates.
  • -f: This option specifies that tail should keep the file open and display updates as new lines are added to it.
  • ${path_to_main_directory}: This is a placeholder for the actual path to the main directory you want to monitor. You need to replace it with the appropriate directory path. For example, /var/log or /home/user/logs.
  • /**/*.log: This pattern is known as a glob pattern and it represents all files with the .log extension within the main directory and its subdirectories. /**/ signifies any nested subdirectory level, and *.log matches any file ending with .log.

When the command is executed, it will continuously display the last few lines of all the log files in the specified directory and its subdirectories. Whenever new lines are appended to any log file, tail will automatically update and display those new lines on the terminal.

This explanation was created by an AI. In most cases those are correct. But please always be careful and never run a command you are not sure if it is safe.

Questions that are answered by this command:

  • How to use glob to follow all changes in different logfiles in different directories?
back to the tail tool