I need a command that acts like tail -f (displays file changes in realtime), but it should display the new output for all files (even if the new file is created/added). I don't know what files will be there in the directory I need to listen, that's why I need it.

I found out that tail -f folder_name/* does what I want, but it doesn't work if I'll add a new file, it wouldn't display its changes.

Is there a way to accomplish what I need?


Looks like a very similar question was asked before.

monitor files (ala tail -f) in an entire directory (even new ones)

Essentially tail -f does not work as you expect because the * wildcard was expanded at execution time and tail isn't build to keep evaluating. You need to use a different app.

There are good solutions suggested in the answers to the previous question. The three I noticed are inotify, multitail, and xtail. It probably best to get more details about those in the other answers.

| improve this answer | |
  • Good find, and welcome to U&L! The right thing to do in this case would be to flag this question as a duplicate of the other question. – Jeff Schaller May 16 '17 at 21:59

Reflex might be useful to you. It can watch a directory and run a command when files change. Written in Go.


| improve this answer | |

Not the answer you're looking for? Browse other questions tagged or ask your own question.