alternative to `tail -f ` allowing printing continuous stream from multiple files in multiple folders under...
up vote
0
down vote
favorite
This question already has an answer here:
How to tail multiple files using tail -0f in Linux/AIX
7 answers
As far as I know, tail -f <filename>
allows to continuously print newly appended data from one single file.
What if I need to get content from multiple files located in multiple folders under the same parent folder, then filter that content if need be, and finally print it as a real-time stream, as new data gets appended to any one of the multiple monitored files?
EDIT: the operating system is RedHat Enterprise Linux 7.4
rhel tail
marked as duplicate by Stephen Kitt, Jeff Schaller, Christopher, RalfFriedl, thrig Dec 5 at 0:03
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.
add a comment |
up vote
0
down vote
favorite
This question already has an answer here:
How to tail multiple files using tail -0f in Linux/AIX
7 answers
As far as I know, tail -f <filename>
allows to continuously print newly appended data from one single file.
What if I need to get content from multiple files located in multiple folders under the same parent folder, then filter that content if need be, and finally print it as a real-time stream, as new data gets appended to any one of the multiple monitored files?
EDIT: the operating system is RedHat Enterprise Linux 7.4
rhel tail
marked as duplicate by Stephen Kitt, Jeff Schaller, Christopher, RalfFriedl, thrig Dec 5 at 0:03
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.
Did you search formultitail
?
– Kusalananda
Dec 4 at 14:13
@StéphaneChazelas RedHat 7.4
– KiriSakow
Dec 4 at 17:57
1
Are new files or directories being created/removed there while you'retail
ing that folder? If yes, should they be dynamically added to the list of files to monitor? May there be hard links or symlinks?
– Stéphane Chazelas
Dec 4 at 18:01
@StéphaneChazelas yes indeed new folders with new files are dynamically added, and these new ones are to be monitored too. Please take a look at my own answer below and tell me what you think.
– KiriSakow
Dec 4 at 18:07
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
This question already has an answer here:
How to tail multiple files using tail -0f in Linux/AIX
7 answers
As far as I know, tail -f <filename>
allows to continuously print newly appended data from one single file.
What if I need to get content from multiple files located in multiple folders under the same parent folder, then filter that content if need be, and finally print it as a real-time stream, as new data gets appended to any one of the multiple monitored files?
EDIT: the operating system is RedHat Enterprise Linux 7.4
rhel tail
This question already has an answer here:
How to tail multiple files using tail -0f in Linux/AIX
7 answers
As far as I know, tail -f <filename>
allows to continuously print newly appended data from one single file.
What if I need to get content from multiple files located in multiple folders under the same parent folder, then filter that content if need be, and finally print it as a real-time stream, as new data gets appended to any one of the multiple monitored files?
EDIT: the operating system is RedHat Enterprise Linux 7.4
This question already has an answer here:
How to tail multiple files using tail -0f in Linux/AIX
7 answers
rhel tail
rhel tail
edited Dec 4 at 18:10
asked Dec 4 at 14:11
KiriSakow
54
54
marked as duplicate by Stephen Kitt, Jeff Schaller, Christopher, RalfFriedl, thrig Dec 5 at 0:03
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.
marked as duplicate by Stephen Kitt, Jeff Schaller, Christopher, RalfFriedl, thrig Dec 5 at 0:03
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.
Did you search formultitail
?
– Kusalananda
Dec 4 at 14:13
@StéphaneChazelas RedHat 7.4
– KiriSakow
Dec 4 at 17:57
1
Are new files or directories being created/removed there while you'retail
ing that folder? If yes, should they be dynamically added to the list of files to monitor? May there be hard links or symlinks?
– Stéphane Chazelas
Dec 4 at 18:01
@StéphaneChazelas yes indeed new folders with new files are dynamically added, and these new ones are to be monitored too. Please take a look at my own answer below and tell me what you think.
– KiriSakow
Dec 4 at 18:07
add a comment |
Did you search formultitail
?
– Kusalananda
Dec 4 at 14:13
@StéphaneChazelas RedHat 7.4
– KiriSakow
Dec 4 at 17:57
1
Are new files or directories being created/removed there while you'retail
ing that folder? If yes, should they be dynamically added to the list of files to monitor? May there be hard links or symlinks?
– Stéphane Chazelas
Dec 4 at 18:01
@StéphaneChazelas yes indeed new folders with new files are dynamically added, and these new ones are to be monitored too. Please take a look at my own answer below and tell me what you think.
– KiriSakow
Dec 4 at 18:07
Did you search for
multitail
?– Kusalananda
Dec 4 at 14:13
Did you search for
multitail
?– Kusalananda
Dec 4 at 14:13
@StéphaneChazelas RedHat 7.4
– KiriSakow
Dec 4 at 17:57
@StéphaneChazelas RedHat 7.4
– KiriSakow
Dec 4 at 17:57
1
1
Are new files or directories being created/removed there while you're
tail
ing that folder? If yes, should they be dynamically added to the list of files to monitor? May there be hard links or symlinks?– Stéphane Chazelas
Dec 4 at 18:01
Are new files or directories being created/removed there while you're
tail
ing that folder? If yes, should they be dynamically added to the list of files to monitor? May there be hard links or symlinks?– Stéphane Chazelas
Dec 4 at 18:01
@StéphaneChazelas yes indeed new folders with new files are dynamically added, and these new ones are to be monitored too. Please take a look at my own answer below and tell me what you think.
– KiriSakow
Dec 4 at 18:07
@StéphaneChazelas yes indeed new folders with new files are dynamically added, and these new ones are to be monitored too. Please take a look at my own answer below and tell me what you think.
– KiriSakow
Dec 4 at 18:07
add a comment |
2 Answers
2
active
oldest
votes
up vote
0
down vote
accepted
Use the following oneliner:
while true; do cat /path/to/numerous/folders/and/files/*/*.txt | grep "some filter" | tail -n 10; sleep 1; done
Every 1 second, the script will print 10 last lines of the filtered stream.
To break the loop, press CtrlC.
Is this really what you wanted? Unliketail -f
, it will repeat the same lines over and over if there is no change, and can miss lines if more than 10 lines are added to a file in the 1-second window.
– n.st
Dec 4 at 23:18
@n.st This oneliner did the job pretty well so far. At least for the time being.
– KiriSakow
Dec 4 at 23:43
add a comment |
up vote
-1
down vote
Try this command:
ls /path/to/files/to/be/monitored/by/tail | while read fname; do tail -f $fname & done; wait
There was a typo:ls /path/to/files/to/be/monitored/by/tail | while read fname; do tail -f $fname &; done
– Alireza Kazemi
Dec 4 at 14:30
1
Please edit your answer to fix the typo. You don't need to comment on it.
– roaima
Dec 4 at 15:12
add a comment |
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
accepted
Use the following oneliner:
while true; do cat /path/to/numerous/folders/and/files/*/*.txt | grep "some filter" | tail -n 10; sleep 1; done
Every 1 second, the script will print 10 last lines of the filtered stream.
To break the loop, press CtrlC.
Is this really what you wanted? Unliketail -f
, it will repeat the same lines over and over if there is no change, and can miss lines if more than 10 lines are added to a file in the 1-second window.
– n.st
Dec 4 at 23:18
@n.st This oneliner did the job pretty well so far. At least for the time being.
– KiriSakow
Dec 4 at 23:43
add a comment |
up vote
0
down vote
accepted
Use the following oneliner:
while true; do cat /path/to/numerous/folders/and/files/*/*.txt | grep "some filter" | tail -n 10; sleep 1; done
Every 1 second, the script will print 10 last lines of the filtered stream.
To break the loop, press CtrlC.
Is this really what you wanted? Unliketail -f
, it will repeat the same lines over and over if there is no change, and can miss lines if more than 10 lines are added to a file in the 1-second window.
– n.st
Dec 4 at 23:18
@n.st This oneliner did the job pretty well so far. At least for the time being.
– KiriSakow
Dec 4 at 23:43
add a comment |
up vote
0
down vote
accepted
up vote
0
down vote
accepted
Use the following oneliner:
while true; do cat /path/to/numerous/folders/and/files/*/*.txt | grep "some filter" | tail -n 10; sleep 1; done
Every 1 second, the script will print 10 last lines of the filtered stream.
To break the loop, press CtrlC.
Use the following oneliner:
while true; do cat /path/to/numerous/folders/and/files/*/*.txt | grep "some filter" | tail -n 10; sleep 1; done
Every 1 second, the script will print 10 last lines of the filtered stream.
To break the loop, press CtrlC.
answered Dec 4 at 14:15
KiriSakow
54
54
Is this really what you wanted? Unliketail -f
, it will repeat the same lines over and over if there is no change, and can miss lines if more than 10 lines are added to a file in the 1-second window.
– n.st
Dec 4 at 23:18
@n.st This oneliner did the job pretty well so far. At least for the time being.
– KiriSakow
Dec 4 at 23:43
add a comment |
Is this really what you wanted? Unliketail -f
, it will repeat the same lines over and over if there is no change, and can miss lines if more than 10 lines are added to a file in the 1-second window.
– n.st
Dec 4 at 23:18
@n.st This oneliner did the job pretty well so far. At least for the time being.
– KiriSakow
Dec 4 at 23:43
Is this really what you wanted? Unlike
tail -f
, it will repeat the same lines over and over if there is no change, and can miss lines if more than 10 lines are added to a file in the 1-second window.– n.st
Dec 4 at 23:18
Is this really what you wanted? Unlike
tail -f
, it will repeat the same lines over and over if there is no change, and can miss lines if more than 10 lines are added to a file in the 1-second window.– n.st
Dec 4 at 23:18
@n.st This oneliner did the job pretty well so far. At least for the time being.
– KiriSakow
Dec 4 at 23:43
@n.st This oneliner did the job pretty well so far. At least for the time being.
– KiriSakow
Dec 4 at 23:43
add a comment |
up vote
-1
down vote
Try this command:
ls /path/to/files/to/be/monitored/by/tail | while read fname; do tail -f $fname & done; wait
There was a typo:ls /path/to/files/to/be/monitored/by/tail | while read fname; do tail -f $fname &; done
– Alireza Kazemi
Dec 4 at 14:30
1
Please edit your answer to fix the typo. You don't need to comment on it.
– roaima
Dec 4 at 15:12
add a comment |
up vote
-1
down vote
Try this command:
ls /path/to/files/to/be/monitored/by/tail | while read fname; do tail -f $fname & done; wait
There was a typo:ls /path/to/files/to/be/monitored/by/tail | while read fname; do tail -f $fname &; done
– Alireza Kazemi
Dec 4 at 14:30
1
Please edit your answer to fix the typo. You don't need to comment on it.
– roaima
Dec 4 at 15:12
add a comment |
up vote
-1
down vote
up vote
-1
down vote
Try this command:
ls /path/to/files/to/be/monitored/by/tail | while read fname; do tail -f $fname & done; wait
Try this command:
ls /path/to/files/to/be/monitored/by/tail | while read fname; do tail -f $fname & done; wait
edited Dec 4 at 15:13
roaima
42.5k551116
42.5k551116
answered Dec 4 at 14:28
Alireza Kazemi
11
11
There was a typo:ls /path/to/files/to/be/monitored/by/tail | while read fname; do tail -f $fname &; done
– Alireza Kazemi
Dec 4 at 14:30
1
Please edit your answer to fix the typo. You don't need to comment on it.
– roaima
Dec 4 at 15:12
add a comment |
There was a typo:ls /path/to/files/to/be/monitored/by/tail | while read fname; do tail -f $fname &; done
– Alireza Kazemi
Dec 4 at 14:30
1
Please edit your answer to fix the typo. You don't need to comment on it.
– roaima
Dec 4 at 15:12
There was a typo:
ls /path/to/files/to/be/monitored/by/tail | while read fname; do tail -f $fname &; done
– Alireza Kazemi
Dec 4 at 14:30
There was a typo:
ls /path/to/files/to/be/monitored/by/tail | while read fname; do tail -f $fname &; done
– Alireza Kazemi
Dec 4 at 14:30
1
1
Please edit your answer to fix the typo. You don't need to comment on it.
– roaima
Dec 4 at 15:12
Please edit your answer to fix the typo. You don't need to comment on it.
– roaima
Dec 4 at 15:12
add a comment |
Did you search for
multitail
?– Kusalananda
Dec 4 at 14:13
@StéphaneChazelas RedHat 7.4
– KiriSakow
Dec 4 at 17:57
1
Are new files or directories being created/removed there while you're
tail
ing that folder? If yes, should they be dynamically added to the list of files to monitor? May there be hard links or symlinks?– Stéphane Chazelas
Dec 4 at 18:01
@StéphaneChazelas yes indeed new folders with new files are dynamically added, and these new ones are to be monitored too. Please take a look at my own answer below and tell me what you think.
– KiriSakow
Dec 4 at 18:07