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...
but the foo.txt file is 0 in size.
tar -xvf foo.tar &1 > ./install_info/foo.txt
Thanx in advance.
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.