Welcome to WebmasterWorld Guest from

Forum Moderators: bakedjake

Message Too Old, No Replies

Tar all files and exclude a folder?

How to tar all files and folders in current folder except one folder?

10:53 pm on Mar 11, 2008 (gmt 0)

Junior Member

10+ Year Member

joined:Nov 8, 2005
votes: 0

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

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


12:06 am on Mar 12, 2008 (gmt 0)

Senior Member from KZ 

WebmasterWorld Senior Member lammert is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Jan 10, 2005
posts: 2935
votes: 23

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*)
4:43 pm on Mar 12, 2008 (gmt 0)

Junior Member

10+ Year Member

joined:May 25, 2006
votes: 0

You might also try this:

tar -cf all.tar --exclude test *


Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members