homepage Welcome to WebmasterWorld Guest from 54.205.122.62
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Hardware and OS Related Technologies / Linux, Unix, and *nix like Operating Systems
Forum Library, Charter, Moderators: bakedjake

Linux, Unix, and *nix like Operating Systems Forum

    
Tar all files and exclude a folder?
How to tar all files and folders in current folder except one folder?
sunroof

5+ Year Member



 
Msg#: 3597896 posted 10:53 pm on Mar 11, 2008 (gmt 0)

How to tar all files, folders, subfolders... in current folder except one folder named 'test'?

something like: tar -cf all.tar * + exclude 'test'

Thanks

 

lammert

WebmasterWorld Senior Member lammert us a WebmasterWorld Top Contributor of All Time 5+ Year Member



 
Msg#: 3597896 posted 12:06 am on Mar 12, 2008 (gmt 0)

You first need to allow extended wildcard options, you can then exclude files or directories from the tar command line. I use the following commands to backup everything in /usr/src, except for the sub directories that start with "linux-2.6". You need to experiment a little to see how you have to construct the excluding wildcard options for your situation.

shopt -s extglob
/bin/tar -cf all.tar usr/src/!(linux-2.6*)

OutdoorWebcams

5+ Year Member



 
Msg#: 3597896 posted 4:43 pm on Mar 12, 2008 (gmt 0)

You might also try this:

tar -cf all.tar --exclude test *

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Hardware and OS Related Technologies / Linux, Unix, and *nix like Operating Systems
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved