LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
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 05-10-2011, 10:14 AM   #1
amario26
LQ Newbie
 
Registered: Apr 2011
Posts: 11

Rep: Reputation: 0
how to exclude multiple directories


Hi,

I am trying to exclude multiple directories when using tar. I can do it for just one directory with --exclude=directory

I can also do it for multiple directories by typing that code again and again. But.. I now have this:

Code:
tar -czpv --exclude="$EXCLUDE"
where the $EXCLUDE is a variable that looks like this:

Code:
EXCLUDE=".gnome2 excludingtest'
As you can see im trying to call this variable that has endless amounts of directories in it seperated by a space.. but when run it doesnt work! It will however work if i just put one directory in the variable. Any ideas?

Many thanks!

Also.. i tried --exclude-tag --exclude-tag-all --exclude-tag-under but to no avail.

Any help would be greatly appreciated!

Thanks
 
Old 05-10-2011, 10:28 AM   #2
SL00b
Member
 
Registered: Feb 2011
Location: LA, US
Distribution: SLES
Posts: 375

Rep: Reputation: 112Reputation: 112
The tar exclude statement is not in the form --exclude=directory, it's in the form --exclude PATTERN. If there was a common naming pattern to the directories you wanted to exclude, (dir01, dir02, etc.), then that's the way you would accomplish that.

You can also use the --exclude-from FILE parameter, where the named file contains a list of files to be excluded. I'm not sure if it could be used to just specify directories instead, but it might be worth a shot.

Another method would be to run multiple tar commands for each directory you actually want to back up, and append them all to the file created in the first one.
 
Old 05-11-2011, 04:47 AM   #3
amario26
LQ Newbie
 
Registered: Apr 2011
Posts: 11

Original Poster
Rep: Reputation: 0
Cheers SL00b, but I figured it out using this:

Code:
-X <(for i in ${EXCLUDE}; do echo $i; done)
 
  


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
[SOLVED] How do I exclude multiple directories in awk with find? Damarr Linux - Newbie 11 05-24-2010 03:52 PM
tar exclude directories kais1 Linux - Newbie 1 10-13-2009 10:01 AM
CVS Exclude : Exclude sub directories from check out On Linux from command line shajay12 Linux - Newbie 1 08-03-2009 01:36 AM
exclude directories from find noir911 Linux - General 3 11-22-2006 07:39 AM
KDAR Q-how to exclude directories... cbjhawks SUSE / openSUSE 1 10-02-2006 05:05 PM


All times are GMT -5. The time now is 09:00 PM.

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