LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 01-22-2002, 10:16 AM   #1
heatlill
LQ Newbie
 
Registered: Jan 2002
Location: Pittsburgh
Distribution: RedHat 7.2-7.3-8.0, Slackware 8-9
Posts: 12

Rep: Reputation: 0
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
 
Old 01-22-2002, 10:24 AM   #2
lfslinux
LFS Maintainer
 
Registered: Jan 2002
Location: Canmore, Alberta, Canada
Distribution: Linux From Scratch
Posts: 372

Rep: Reputation: 30
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.
 
Old 01-22-2002, 10:27 AM   #3
heatlill
LQ Newbie
 
Registered: Jan 2002
Location: Pittsburgh
Distribution: RedHat 7.2-7.3-8.0, Slackware 8-9
Posts: 12

Original Poster
Rep: Reputation: 0
Wow. That was fast and very helpful. Thanks.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Redirecting to file and stdout Quantum0726 Programming 3 11-14-2005 08:35 PM
redirecting stdout and stderr to a file Avatar33 Programming 4 03-12-2005 07:55 AM
Redirecting stdout to tar hari_s_82 Linux - Newbie 6 10-08-2004 01:49 AM
redirecting stdin and stdout with pipes: convincing apps they're for a terminal? prell Programming 1 09-02-2004 06:38 AM
tar from contents of a text file trpn Linux - General 3 03-08-2004 01:05 AM


All times are GMT -5. The time now is 02:02 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration