1

This question already has an answer here:

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?

marked as duplicate by Jeff Schaller, thrig, mdpc, Gilles 'SO- stop being evil', don_crissti May 17 '17 at 0:34

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

2

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.

  • 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
1

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

https://github.com/cespare/reflex

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