LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Redirecting stdout from tar to a text file. (https://www.linuxquestions.org/questions/programming-9/redirecting-stdout-from-tar-to-a-text-file-12372/)

heatlill 01-22-2002 10:16 AM

Redirecting stdout from tar to a text file.
 
Hello all this is my first post ever. *woohoo*. Anyhow I have been looking on the net to find a way to capture the stdout messages of tar when i extract a tar file. I tried this...

Code:

tar -xvf foo.tar &1 > ./install_info/foo.txt
but the foo.txt file is 0 in size.

Any ideas?

Thanx in advance.
Heath

lfslinux 01-22-2002 10:24 AM

Re: Redirecting stdout from tar to a text file.
 
Quote:

Originally posted by heatlill
Hello all this is my first post ever. *woohoo*. Anyhow I have been looking on the net to find a way to capture the stdout messages of tar when i extract a tar file. I tried this...

Code:

tar -xvf foo.tar &1 > ./install_info/foo.txt
but the foo.txt file is 0 in size.

Any ideas?

Thanx in advance.
Heath

You have a typo there. &1 > doesn't redirect in the way you think it to. The & will cause tar to run in the background so output isn't sent to stdout, so the redirection doesn't work.

Secondly, the "1 >" construction won't work, you can't put a space between 1 and >, bash won't recognise this as you trying to redirect file descriptor 1 (stdout). Try 1> foo.txt or just > foot.txt (since > file is the same as 1> file)

tar xvf somefile.tar > foo.txt will work the way you expect.

heatlill 01-22-2002 10:27 AM

Wow. That was fast and very helpful. Thanks.


All times are GMT -5. The time now is 08:33 PM.