Jump to content
section31

non-recursive Tar

Recommended Posts

Is there a simple way to do a non-recursive tar.

 

I've come up with a few sites that say there is a flag -n for it, but the distro (fedora 3) i'm using doesn't have that option. Any other alternatives?

Share this post


Link to post
Share on other sites
Is there a simple way to do a non-recursive tar. 

 

I've come up with a few sites that say there is a flag -n for it, but the distro (fedora 3) i'm using doesn't have that option.  Any other alternatives?

 

please explain more cause i didnt understand

Share this post


Link to post
Share on other sites

hm, not sure If I can make it any clearer but I'll try. Lets say I'm making a gzip tarball.

tar -cvzf archive.tar.gz foobarDirectory/

This will tar everything in foobarDirectory including all of the subdirectories in it, hence being recursive.

 

I would like to know how would I go about taring a directory that doesn't tar its subdirectorys, but just the contents within that directory. A simple flag doesn't seem like an option as I looked in the man page and didn't see one. So, I will need to find an alternative, and if anyone could help that would be cool. It would probably involve a find piped with tar or something, but then again find is recursive also so I don't know.

Share this post


Link to post
Share on other sites

Ok, after toying around I came up with this. I don't know if its the most efficient way though.

 

find foobarDir/ -name *.jpg -maxdepth 1 | xargs tar -cvzf backup.tar.gz

Share this post


Link to post
Share on other sites

find foobarDir/ -name *.jpg -maxdepth 1 | xargs tar -cvzf backup.tar.gz

equals

 

tar -cvzf backup.tar.gz foobarDir/*.jpg

 

GNU tar also offers the "--no-recursion" parameter (kinda bad documented) where it skips directory contents.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...