_bhi
March 19, 2012, 11:32am
1
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
_bhi
March 19, 2012, 1:46pm
3
Is there any other option --line-buffered is not supported.
_bhi
March 20, 2012, 11:26pm
6
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?
_bhi
March 23, 2012, 5:47am
10
Thanks
Case insensitive is not needed.