Redirecting STDOUT

jhall at vandaliamo.net jhall at vandaliamo.net
Fri Dec 21 09:34:55 PST 2007


> In that case you only redirecting STDERR to file. As you've been
> already told STDOUT will be redirected with
>
> $ command 1>file
>
> or
>
> $ command > file
>
> adding 2>&1 will also redirect STDERR to this file
>

When I run this as a non-root user it works fine.  But, when running it as
root, it does not produce the expected results.

$ ls -l /fjdkslafjdl 2>/home/hallja/test2
And, in the file test2, I see

ls: /fjdkslafjdl: No such file or directory

Running the same command as root, I receive the following results.
# ls -l /fjdkslafjdl 2>/home/hallja/test2
ls: /fjdkslafjdl: No such file or directory

And, in /home/hallja/test2 I see the following.
-rw-r--r--  1 root  hallja  0 Dec 21 08:02 2

Why does this not work as root?

Thanks,


Jay



More information about the freebsd-questions mailing list