Re: Redirecting STDOUT



On 14:49:28 Dec 21, jhall@xxxxxxxxxxxxxx wrote:
I am in the process of debugging a script and I would like to have the
output of stdout redirected to a file.

After reading about redirection on the Internet, I was under the
impression the following would redirect stdout to a file, but I cannot
seem to get it to work.

tar -cvzf root.tgz /root > /dev/null 2>/home/jay/tarlog

I'm sure it is something simple I am doing wrong, but I am not seeing it.

Yes. Very simple indeed.

This is highly shell dependent but on ksh, this command works.

$ tar zcvf root.tgz /root >/home/jay/tarlog 2>/dev/null

The above command will redirect stderr (fdes 2) to the bit bucket and
stdout to /home/jay/tarlog.

If you wish to redirect both stderr and stdout to a single file, you can
try this command.

$ tar zcvf root.tgz /root >/home/jay/tarlog 2>&1

-Girish
_______________________________________________
freebsd-questions@xxxxxxxxxxx mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "freebsd-questions-unsubscribe@xxxxxxxxxxx"



Relevant Pages

  • Re: last character of the last line is a newline?
    ... Would it be possible to redirect only to a file. ... output to standard output. ... # to stdout and to your_file ... Substitute your_program by the compound command of your original posting: ...
    (comp.unix.shell)
  • Re: Start a program and get a hold of its STDOUT and STDIN?
    ... one would just redirect it on the command line: ... > was examples of getting STDIN or STDOUT but not both at ... I need this to be in real time (when the ...
    (comp.lang.perl.misc)
  • Re: Backgrounding a stream, and sendmail?
    ... >> just redirect the output to a file instead of sendmail.) ... > shell command like ... when prog_b has it's stdout redirected nothing ... > is done instead of printing to stdout you could start sendmail from within ...
    (comp.os.linux.development.apps)
  • Re: Cron Daemon backup message too big
    ... What this command does is to concatenate stdout + errors and redirect ... Could I avoid this by terminating the command line instead like this: ... though you need a redirect to the file too like so: ...
    (Debian-User)
  • Re: freopen on both stdout and stderr
    ... a while ago I was pointed towards freopen as a way to redirect stderr to a log file. ... but apparently the app also writes a few lines to stdout. ... Now I could redirect to 2 separate files, but would rather keep the 2 flows together. ...
    (comp.lang.c)