LinuxQuestions.org
Visit Jeremy's Blog.
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 11-30-2011, 10:32 AM   #1
ted_chou12
Member
 
Registered: Aug 2010
Location: Zhongli, Taoyuan
Distribution: slackware, windows, debian (armv4l GNU/Linux)
Posts: 424
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:
/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
 
Old 11-30-2011, 01:19 PM   #2
corp769
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.

Cheers,

Josh

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

Last edited by corp769; 11-30-2011 at 01:20 PM.
 
1 members found this post helpful.
Old 11-30-2011, 11:44 PM   #3
ted_chou12
Member
 
Registered: Aug 2010
Location: Zhongli, Taoyuan
Distribution: slackware, windows, debian (armv4l GNU/Linux)
Posts: 424
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)
Thanks,
Ted
 
Old 12-01-2011, 07:42 AM   #4
jschiwal
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.
  


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


All times are GMT -5. The time now is 05:22 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