error output redirection

Polytropon freebsd at
Sun Oct 11 21:59:01 UTC 2009

On Sun, 11 Oct 2009 23:36:52 +0200, Stefan Miklosovic <miklosovic.freebsd at> wrote:
> hi list,
> if error output of some program appear on screen,
> it is possible to print it also to some file simultaneously ?
> e.g
> if I "cat" file which do not exist, error is on screen,
> I want to add that error to some file (errors.txt)

See "man sh" (or "man bash" if you use it): The redirection
could be this:

	$ cat nonexist.txt > error.txt 2>&1

The C shell has a different syntax:

	% cat nonexist.txt >& error.txt

I hope that's what you have requested. :-)

Magdeburg, Germany
Happy FreeBSD user since 4.0
Andra moi ennepe, Mousa, ...

More information about the freebsd-questions mailing list