LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   tar (compress) specific files (https://www.linuxquestions.org/questions/linux-newbie-8/tar-compress-specific-files-916376/)

ted_chou12 11-30-2011 09:32 AM

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:
/etc/init.d/samba
/etc/init.d/samba2
/usb/sda1/smbd
/usb/sda1/nmbd
These are all of the scripts that I wish to include. I wish to make a single .tar file so when
Code:

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.
Thanks,
Ted

corp769 11-30-2011 12:19 PM

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.

Cheers,

Josh

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

ted_chou12 11-30-2011 10:44 PM

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)
Thanks,
Ted

jschiwal 12-01-2011 06:42 AM

tar -C / -xzf /usb/sda1/scripts.tgz


All times are GMT -5. The time now is 07:50 PM.