How to use tail in combination with sed .

bash

Solution

The problem is that `grep` sees that it's not writing to the terminal, so it buffers its output, eventually writing big chunks that `sed` can process all at once. To tell it to print out lines as soon as they're available, use the `--line-buffered` option:

tail -f mylogs.log \
  | grep --line-buffered Exception \
  | sed -u -e $'s/Exception/Exception\a/'

(Note that I've also added the `-u` flag to `sed`, which is similar to `grep`'s `--line-buffered` option. In my testing it didn't seem to make a difference for this command, but I figure it's better to include it just in case.)

Problem

I want to beep a Sound , incase there is any Exception ocured in Log Files . I am using bash script . But unfortunately when tail is used in combintaion with sed , it doesn't work . I have tried with the below commands and posting here . ``` tail -f mylogs.log | grep "Exception" | sed -e $'s/Exception/Exception\a/' tail -f mylogs.log | sed -e $'s/Exception/Exception\a/' tail -f mylogs.log | grep "Exception" | sed -e $'s/Exception/Exception\a/' ```

Original source