Help answer threads with 0 replies.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
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!


  Search this Thread
Old 11-30-2011, 09:32 AM   #1
Registered: Aug 2010
Location: Zhongli, Taoyuan
Distribution: slackware, windows, debian (armv4l GNU/Linux)
Posts: 425
Blog Entries: 28

Rep: Reputation: 2
tar (compress) specific files

Hi, there are some scripts I wish to share with some other people, but in order to make their lives easier, I wish to compress files into a tar file that upon a single command is prompt, all of the tarred scripts will go into the already existing directories, for example.
The scripts that I wish to tar are already in the existing directories on my machine:
These are all of the scripts that I wish to include. I wish to make a single .tar file so when
tar -xzf "/usb/sda1/scripts.tgz"
is entered, all of the scripts go to the correct folders on the new system, all of these folders will be "already existing"
Sorry it might be a bit hard to understand, I am trying to explain myself as best as I can. Let me know if there are pts i need to clarify.
Old 11-30-2011, 12:19 PM   #2
LQ Guru
Registered: Apr 2005
Posts: 5,817

Rep: Reputation: 1002Reputation: 1002Reputation: 1002Reputation: 1002Reputation: 1002Reputation: 1002Reputation: 1002Reputation: 1002
About the easiest way to go with this one would be to create absolute directories within your tarball, and on the computer you want to extract it to, just extract in / instead of a typical home directory or temp directory. Doing it this way would result in extracting the files into their needed places.



Edit - Just noticed something too.... The link in your signature doesn't work, FYI

Last edited by corp769; 11-30-2011 at 12:20 PM.
1 members found this post helpful.
Old 11-30-2011, 10:44 PM   #3
Registered: Aug 2010
Location: Zhongli, Taoyuan
Distribution: slackware, windows, debian (armv4l GNU/Linux)
Posts: 425
Blog Entries: 28

Original Poster
Rep: Reputation: 2
Hi, thanks for your reply, but the machine (by default) has no space in the root directory, so when the tar ball is downloaded, it typically goes to the /usb/sda1/file.tar directory. I wonder if there is a command that could resolve this? (decompressing it at /usb/sda1/file.tar directory but still be able to put files into their expected directories)
Old 12-01-2011, 06:42 AM   #4
LQ Guru
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 671Reputation: 671Reputation: 671Reputation: 671Reputation: 671Reputation: 671
tar -C / -xzf /usb/sda1/scripts.tgz
1 members found this post helpful.


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
LXer: Compress your files using tar and gzip utility LXer Syndicated Linux News 0 07-31-2011 03:12 PM
tar with parameter -T (or --files-from) does not compress? Babelduo Linux - Server 3 01-18-2011 08:23 AM
using tar to compress specific files in a directory named a certain way slinky66 Linux - Newbie 3 11-25-2009 01:31 PM
tar doesn't compress .hidden files in the same directory it is run in? BassKozz Linux - Newbie 2 06-02-2009 04:46 PM
compress a directory using tar muskiediver Linux - General 4 07-18-2006 10:24 AM

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

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