Skip to main content
20 events
when toggle format what by license comment
Nov 19, 2020 at 19:19 history closed Chris Davies
bu5hman
jsbillings
elbarna
Stewart
Duplicate of tail a log util keywords found or timeout
Nov 17, 2020 at 20:37 comment added ctrl-alt-delor use a different command in place of sed, one that will terminate when done. When it terminates the pipes will be closed, and tail will exit. consider awk.
Nov 17, 2020 at 20:35 history edited ctrl-alt-delor CC BY-SA 4.0
spelling
Oct 25, 2020 at 19:40 answer added user313992 timeline score: 6
Oct 25, 2020 at 18:28 comment added user313992 @glenn does it matter? do you know any reliable way from a pipe reader to kill the pipe writer, which does not depend on /proc filesystem, does not assume that they're both part of the same process group, does not assume that pipes aren't implemented with sockets (as in ksh), and will happen immediately, not when the writer tries to write something else (which may never come).
Oct 20, 2020 at 12:14 comment added glenn jackman How to kill the tail -f process after finding the special string? -- same class?
Oct 20, 2020 at 10:46 comment added Kusalananda You may also want to mention what Unix you are using.
Oct 20, 2020 at 9:31 answer added Jaap Joris Vens timeline score: 2
Oct 20, 2020 at 9:07 comment added Kusalananda @AbhaySingh If you're using bash, then mention that in the question. If you have found a solution, then post it as an answer along with an explanation of the issue and of how your solution solves the issue.
Oct 20, 2020 at 9:05 comment added Abhay Singh { sed '/.special string/q' | tee "$output" ; kill -s PIPE "$!"; } < <(exec tail -f logfile) gives me the solution for the problem @kusalananda
Oct 20, 2020 at 8:21 comment added Kusalananda Please provide actual data and the actual pattern that you are using. Don't provide placeholder values. Since at least three people have asked about this specific thing today, we must assume that it is a school assignment. As a school assignment, the data probably does not contain personal details that needs to be censored.
Oct 20, 2020 at 7:53 comment added Abhay Singh yes, it matches and writes the lines to output.txt file till "special string" matches. But tail -f function , I thinks still is not terminated., because the program is struck on this line.
Oct 20, 2020 at 7:47 comment added Kusalananda Is your pattern, special string, matching anything in the log file when interpreted as a regular expression?
Oct 20, 2020 at 6:43 comment added Abhay Singh my script still is in the same line, it is not terminating there. @Amir
Oct 20, 2020 at 6:35 comment added Amir In my experimentation, it seems like tail -f hangs around only until its sleep interval ends. So, in order to make it terminate faster, invoke it with --sleep-interval=N, e.g. tail -f -s 0.01 logfile | sed '/special string/q' | tee output.txt.
Oct 20, 2020 at 6:27 review Close votes
Nov 19, 2020 at 19:19
Oct 20, 2020 at 6:10 history edited αғsнιη CC BY-SA 4.0
added 1 character in body; edited tags
Oct 20, 2020 at 6:08 comment added αғsнιη Does this answer your question? tail a log util keywords found or timeout
Oct 20, 2020 at 6:05 review First posts
Oct 20, 2020 at 6:36
Oct 20, 2020 at 6:02 history asked Abhay Singh CC BY-SA 4.0