Decrease buffer size

Hi,
I am using the below command to get the output in a file called "Logs.txt"

 tail -f filename | egrep -i "cpu | hung " >> Logs.txt 

The problem is the Logs.txt file gets updated only after the buffer is 8Kb, but i want to update the file immediately and not wait for the buffer to get 8kb.
Is there a way to decrease the buffer size.

Thanks

If your version of egrep supports it, try --line-buffered

Is there any other option --line-buffered is not supported.

What is your system?

SunOS 5.10

Is there any other way to decrease the buffer size

The problem isn't the buffer size per se, but the fact that it's buffering at all... Maybe try an alternate command:

tail -f filename | nawk '/[cC][pP][uU] | [hH][uU][nN][gG]/'

Or try shell:

tail -f filename | 
while IFS= read -r line; do 
  case $line in  
    (*"cpu "*|*" hung "*) printf "%s\n" "$line"
  esac
done >> Logs.txt

(On Solaris, use bash, ksh, or /usr/xpg4/bin/sh, but do not use /bin/sh)
This is not case insensitive. Does it need to be case insensitive too?

Thanks :b:
Case insensitive is not needed.