New answers tagged

0

I’m taking a stab in the gloom, since I don’t entirely understand the question, but try (sleep 1; command || printf 'command failed with exit code %s.\n' "$?") & if tail -f –n0 "out.log" | grep -q "demo1" then echo "Application started with success." else echo "Startup failed." fi tail -n0 will output the last 0 (zero) lines of the file.  By ...


5

This does what you need: sh -c 'tail -f file & cat' | tee file2 Note, it duplicates your comments for the terminal output when you press enter. It works also with {...} and (...) instead of sh -c, but then tail -f won't stop running when you press ctrl+c.


-1

Use Tee tail -f /var/log/messages | tee test.txt


1

I've found a command. Details are in the question. { sed /"$keywords"/q; kill $!; } < <(exec timeout 1m tail -Fn 0 $log_file) #!/bin/bash and set -euxo pipefail are needed if in a script, which must be executed by bash, not sh, though linked to bash in CentOS.


0

ONLY For VIM 8.0+ they introduced timers, so you could use a timer to simulate tail function, this works pretty effectively in my experience. I have mapped F6 key to turn on tail and F7 to turn off tail, you can customize those in the commands below, also see my section below for WORDS OF CAUTION. Run the following exe ":function! Tail(timer) \n :exe '...


1

I think what's happening here is a race condition. tail --pid=... is depending on tail checking and realising that the tracked PID has died before it gets a SIGPIPE (usually signal no. 13, corresponding to the 128+13=141 exit status you got) from trying to write to a pipe broken by sed terminating. The manual only says "shortly after that process terminates, ...


1

You could do something like: sh -c 'echo "$$"; exec tail -f file' | ( IFS= read -r pid timeout 60 sed "/$keyword/q" kill -s PIPE "$pid" ) Unless you have enabled the pipefail option, that will exit with the exit status of kill which should be 0 unless tail has exited of its own (which shouldn't happen in practice). With pipefail, that would exit ...


Top 50 recent answers are included