On Sunday 22 April 2007 16:13, bilbo wrote: > Recently I faced a strange behaviour of the Linux commands. I have a > log file which contains a lot of information. I wanted to extract some > informations out of it. But when I tried to > > tail -f mylog | grep 'smtg' | sed -n 's/end/notend/p' > > no output could be found. Which was quite surprising since the > following tests did their job without any problem: > > tail -f mylog | grep 'smtg' > tail -f mylog | sed -n 's/end/notend/p' > tail -200 mylog | grep 'smtg' | sed -n 's/end/notend/p' > > So, of course, to achieve this result I simply went for perl. But can > anyone tell me what is the reason why this didn't work?
You did not wait for grep's output buffer to fill and send the first output to sed. Add the --line-buffered switch to the grep command, or use: tail -f mylog | sed -n '/smtg/s/end/notend/p' --Mike Bird -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]