LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
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-20-2010, 02:54 PM   #1
duffsterlp
LQ Newbie
 
Registered: Jul 2010
Posts: 8

Rep: Reputation: 0
TAR subdirectory question


Hi all.
I'm working with an already existing TAR file and I'm trying to insert a file into a subfolder of the TAR archive. Is there a simple way to do this? I don't want to put it in the directory where the TAR is pointing and archive again because it is a long process to archive everything; I want to put it directly into the subfolder of the TAR.

I want to do something like: tar -cf test.tar:/subfolder text.txt

Thanks
 
Old 07-20-2010, 03:13 PM   #2
irmin
Member
 
Registered: Jan 2010
Location: the universe
Distribution: Slackware (modified), Slackware64 (modified), openSuSE (modified)
Posts: 342

Rep: Reputation: 62
Try calling tar with command "r" (append):
Code:
tar rf test.tar subfolder/text.txt
Or use the command "u" (update).
 
Old 07-20-2010, 03:24 PM   #3
duffsterlp
LQ Newbie
 
Registered: Jul 2010
Posts: 8

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by irmin View Post
Try calling tar with command "r" (append):
Code:
tar rf test.tar subfolder/text.txt
Or use the command "u" (update).
Maybe I didn't make myself clear. Text.txt cannot be in the subfolder but I want it to appear in subfolder inside the TAR.
I meant to use an r in my original message instead of c.
Something like tar rf test.tar:/subfolder text.txt
 
Old 07-20-2010, 03:54 PM   #4
irmin
Member
 
Registered: Jan 2010
Location: the universe
Distribution: Slackware (modified), Slackware64 (modified), openSuSE (modified)
Posts: 342

Rep: Reputation: 62
Ok, then try that:
Code:
tar rf test.tar --transform 's%^%subfolder/%' test.txt
You could also try to create a directory 'subfolder', put your file inside this folder and just add this file.
 
Old 07-20-2010, 04:03 PM   #5
duffsterlp
LQ Newbie
 
Registered: Jul 2010
Posts: 8

Original Poster
Rep: Reputation: 0
When I do that I get the following. I created test.tar and test.txt to try it.

sh-3.2$ tar rf test.tar --transform 's%^%subfolder/%' test.txt
tar: unrecognized option `--transform'
Try `tar --help' or `tar --usage' for more information.
sh-3.2$

Maybe that option is deprecated?
 
Old 07-20-2010, 04:10 PM   #6
irmin
Member
 
Registered: Jan 2010
Location: the universe
Distribution: Slackware (modified), Slackware64 (modified), openSuSE (modified)
Posts: 342

Rep: Reputation: 62
This option is a GNU extension to tar.
 
Old 07-20-2010, 04:24 PM   #7
duffsterlp
LQ Newbie
 
Registered: Jul 2010
Posts: 8

Original Poster
Rep: Reputation: 0
I guess that means my computer doesn't support it? Then, how do I get that command to work on my machine? Is there a similar command that is not part of the GNU extension?
 
Old 07-20-2010, 04:30 PM   #8
irmin
Member
 
Registered: Jan 2010
Location: the universe
Distribution: Slackware (modified), Slackware64 (modified), openSuSE (modified)
Posts: 342

Rep: Reputation: 62
I looked at the tar manual and info pages and the only way, as far as I see, is:
Code:
mkdir subfolder
mv test.txt subfolder
tar rf test.tar subfolder/test.txt
But you can download GNU tar (ftp://ftp.gnu.org/gnu/tar) and install it in addition to your native tar command.

Last edited by irmin; 07-21-2010 at 02:23 AM.
 
Old 07-20-2010, 04:41 PM   #9
duffsterlp
LQ Newbie
 
Registered: Jul 2010
Posts: 8

Original Poster
Rep: Reputation: 0
Alright. Thanks for all the help!
 
  


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 can i decompress this tar.tar file? hmmm sounds new.. tar.tar.. help ;) kublador Linux - Software 14 10-25-2016 03:48 AM
a tough question 4 u, problem in extracting tar & tar.gz files p_garg Linux - General 5 11-08-2010 12:02 PM
BackUp & Restore with TAR (.tar / .tar.gz / .tar.bz2 / tar.Z) asgarcymed Linux - General 5 12-31-2006 03:53 AM
tar.gz question <---NOOOOOB QUESTION jairo Linux - Software 4 02-17-2003 06:28 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

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

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