LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 07-23-2008, 08:30 PM   #1
nawuza
Member
 
Registered: Jan 2007
Location: High Castle
Distribution: FC8
Posts: 66

Rep: Reputation: 15
Post tar file listed in the text file


hello.
i am having problem in tar'ing' files listed in a text file.can anyone guide me.
what i did is
tar -czf test.tgz > backup.txt backup2.txt

where did i do wrong?!
 
Old 07-23-2008, 09:38 PM   #2
eggixyz
Member
 
Registered: Apr 2008
Posts: 310

Rep: Reputation: 30
Hey There,

Quote:
tar -czf test.tgz -I backup.txt -I backup2.txt
Depending upon what OS you're running the -I flag could also be -L, -t or -l

Best wishes,

Mike
 
Old 07-23-2008, 09:39 PM   #3
nawuza
Member
 
Registered: Jan 2007
Location: High Castle
Distribution: FC8
Posts: 66

Original Poster
Rep: Reputation: 15
thanks a bunch!!!i am using fedora 8.it doesn't work..isk3

Last edited by nawuza; 07-23-2008 at 09:46 PM.
 
Old 07-23-2008, 10:03 PM   #4
Mr. C.
Senior Member
 
Registered: Jun 2008
Posts: 2,529

Rep: Reputation: 61
I'm sorry, I don't understand what you are trying to do. Perhaps you can clarify
  1. which file will be the tar archive file,
  2. which file(s) will be placed into the archive by tar, and
  3. are you asking how to tell tar to take its list of files from another file ?
 
Old 07-23-2008, 10:45 PM   #5
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.9, Centos 7.3
Posts: 17,362

Rep: Reputation: 2377Reputation: 2377Reputation: 2377Reputation: 2377Reputation: 2377Reputation: 2377Reputation: 2377Reputation: 2377Reputation: 2377Reputation: 2377Reputation: 2377
To expand on Mr C, your cmd switch 'c' creates a tar file and the 'z' compresses it, but you've put the output ( '>' ) into a text file.
In fact that's invalid syntax..

To create a tgz

tar czf file.tgz file1.txt file2.txt ...

to extract

tar zxf file.tgz
 
Old 07-23-2008, 10:51 PM   #6
Mr. C.
Senior Member
 
Registered: Jun 2008
Posts: 2,529

Rep: Reputation: 61
The redirect would be OK, if the goal was to place tar's STDOUT into a text file. Its more useful with -v.

Thanks for the assist, chrism01.
 
Old 07-23-2008, 10:54 PM   #7
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.9, Centos 7.3
Posts: 17,362

Rep: Reputation: 2377Reputation: 2377Reputation: 2377Reputation: 2377Reputation: 2377Reputation: 2377Reputation: 2377Reputation: 2377Reputation: 2377Reputation: 2377Reputation: 2377
Nw. I've never seen the re-direct used quite that way before. Maybe I need to re-read the man page
 
Old 07-23-2008, 11:09 PM   #8
nawuza
Member
 
Registered: Jan 2007
Location: High Castle
Distribution: FC8
Posts: 66

Original Poster
Rep: Reputation: 15
my mistakes..sorry...i realize that the backup.txt is somehow empty..careless me..
 
Old 07-23-2008, 11:31 PM   #9
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 671Reputation: 671Reputation: 671Reputation: 671Reputation: 671Reputation: 671
You can use "-T file" or "--files-from=file" to create an archive of files listed in a file.

You may want to rethink the names of the text files you are using because they are too similar and don't indicate what they are for. I'd suggest something like:
tar czvf backup.tar.gz --file-from=backup_list >archive.log
 
Old 07-23-2008, 11:51 PM   #10
nawuza
Member
 
Registered: Jan 2007
Location: High Castle
Distribution: FC8
Posts: 66

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by jschiwal View Post
You can use "-T file" or "--files-from=file" to create an archive of files listed in a file.

You may want to rethink the names of the text files you are using because they are too similar and don't indicate what they are for. I'd suggest something like:
tar czvf backup.tar.gz --file-from=backup_list >archive.log
thanks jschiwal..
 
Old 07-24-2008, 12:22 AM   #11
Mr. C.
Senior Member
 
Registered: Jun 2008
Posts: 2,529

Rep: Reputation: 61
Quote:
Originally Posted by nawuza View Post
my mistakes..sorry...i realize that the backup.txt is somehow empty..careless me..
It is emptied as soon as you hit Enter on the command line. The shell sets up redirection before the commands are executed. The redirection truncates the file immediately.
 
  


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
How to parse text file to a set text column width and output to new text file? jsstevenson Programming 12 04-23-2008 02:36 PM
gave wrong syntax for tar as tar -cvzf file file.tgz how to recover the file gautham Linux - General 4 04-13-2005 03:15 AM
tar from contents of a text file trpn Linux - General 3 03-08-2004 01:05 AM
Redirecting stdout from tar to a text file. heatlill Programming 2 01-22-2002 10:27 AM


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

Main Menu
Advertisement
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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration