LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   Weird thing in redirecting stdout and stderr (https://www.linuxquestions.org/questions/linux-software-2/weird-thing-in-redirecting-stdout-and-stderr-817392/)

brubizu 07-01-2010 08:13 AM

Weird thing in redirecting stdout and stderr
 
Hi... I'm trying to redirect the progress percentage of the mkisofs command to a zenity window... the thing is, mkisofs prints the xx% to the stderr... so what I'm trying to do is:

Code:

mkisofs options ../filename.iso . 2>&1 | grep done
and that "works"... I mean, it does print the correct lines on the terminal... however if a try to write to a file, or pipe it to another command, awk for example:

Code:

mkisofs options ../filename.iso . 2>&1 | grep done | awk '{print $1}'
it doesn't print anything...

Code:

mkisofs options ../filename.iso . 2>&1 | grep done > foo
this will make foo an empty file...

what am I doing wrong?

brubizu 07-01-2010 09:18 AM

it is working, but the numbers are printed almos all at once at the end of iso building.

Wim Sturkenboom 07-01-2010 11:09 AM

Might be line buffering by grep. Try to use grep --line-buffered

I had a similar issue and matir suggested the above.


All times are GMT -5. The time now is 08:28 PM.