LinuxQuestions.org
Register a domain and help support LQ
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 08-16-2008, 02:13 AM   #1
davidstvz
Member
 
Registered: Jun 2008
Posts: 405

Rep: Reputation: 30
tar questions


I have not found anything obvious in the tar docs that explain this, but I was wondering if any pros know how to do any of the following:

Let's say I want to tar a directory, but only include files not folders. Is there a simple way to do this?

What if I want to tar everything in a directory, but exclude one particular file or folder (or a few)?

I may think of some more questions, but these are most pressing to me.
 
Old 08-16-2008, 02:23 AM   #2
billymayday
LQ Guru
 
Registered: Mar 2006
Location: Sydney, Australia
Distribution: Fedora, CentOS, OpenSuse, Slack, Gentoo, Debian, Arch, PCBSD
Posts: 6,678

Rep: Reputation: 122Reputation: 122
There's the pretty clear --exclude option that you can look up for the second question

In answer to the first, I suspect the answer is not easily, but let me see if I understand what you mean. If this is your structure

Code:
top_dir
    file_1
    file_2
    directory_1
        file_3
you want to tar file_1, file_2 and file_3 (but not as directory/file_3)

What you'd need to do is some form of loop through and sub-directories using -C and --no-recursion while concatonating files to the tarball. However if file_3 was also called file_2 I think you'll have some issues.

If you mean that you just want to tar file_1 and file_2, then --no-recursion should get you there.


Note that tar wants to include the path from where you start unless you use -C
 
Old 08-16-2008, 02:52 AM   #3
Mr. C.
Senior Member
 
Registered: Jun 2008
Posts: 2,529

Rep: Reputation: 61
You could use find -type f to present the file list and use tar's ability to read the file list from STDIN.
 
  


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
BackUp & Restore with TAR (.tar / .tar.gz / .tar.bz2 / tar.Z) asgarcymed Linux - General 5 12-31-2006 03:53 AM
tar questions mattymattmatt Linux - General 1 01-05-2006 07:15 PM
tar questions??? slack66 Linux - Newbie 4 11-14-2005 03:28 PM


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