stderr redirection

Does anyone know away of redirecting the stderr for a bourne or korn shell script to a file.

I though it was the same for all shells?

This shold produce a file 'junk.txt' with an error from stderr

$ RunFail > junk.txt 2>$1

Actually it's:
$ RunFail > junk.txt 2>&1

That is you need an ampersand, not a dollar sign. And that syntax will not work with csh or csh clones.

Thanks Perderabo.

I I rewrite it as:
RunFail >> junk.txt 2>>&1

will it append to the file?

There is no such thing as 2>>&1

>> junk.txt
will open the file in append mode and attach it to fd 1

2>&1
will duplicate fd 1 and attach it to fd 2. You use this form for everything. It does not matter how fd 1 came to exist.

Opps to my typo :o

thanks Perderabo