1

How to redirect stderr in FreeBSD?

Neither of below worked

: ls 2> out.log
ls: 2: No such file or directory

: ls -al 2> error.log
ls: 2: No such file or directory

: (ls -al) 2> error.log
Badly placed ()'s.

How accomplish?

Dims
  • 3,181
  • 9
  • 49
  • 107
  • 6
    This is really about the shell you are using (presumably `csh`), rather than FreeBSD. See for example [stderr redirection not working in csh](https://unix.stackexchange.com/questions/35715/stderr-redirection-not-working-in-csh) – steeldriver Mar 31 '23 at 21:19
  • Once you solve the csh issue, it's also necessary for your test command to generate output on the stderr file descriptor. I don't think `ls` will do that unless you provide a filename on the command line that doesn't exist, for example `ls -l notexist 2> error.log`. – Sotto Voce Mar 31 '23 at 21:34

0 Answers0