How to redirect all std-output from bash to a command like 'grep' or 'sed' to filter the output and then write it to a file?
This is what I want in principle:
exec > >(cat | cat >>/tmp/myoutput.txt).
The last command works as expected.
But if I replace the first
grep -v 'foo' or with
sed 's/foo/bar/g' no data is written into file.
How to get the above example to work with grep or sed?
I would like to filter errormessages from .xsession-errors.
sed -i 's/foo/bar/g' .xsession-errors
is not working because sed replaces the file .xsession-errors and future output from programms is not visible.
So one option to achieve would be to replace a line in /etc/X11/Xsession with code that filters messages.
More info here:
- I used
cat2 times to show that pipes are working like expected in subshell and to route everyting into a file. The
catis of course not needed in final version.
- I had enough output to fill buffers, I think, because I did several
ls /usr/to fill buffers.)
exec | sed ...is not working