LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices



Reply
 
Search this Thread
Old 07-06-2011, 02:44 PM   #1
mahmoodn
Member
 
Registered: May 2010
Posts: 403

Rep: Reputation: 16
--exclude doesn't work with tar command


I don't know why --exclude doesn't work when I use tar command. Please see this code
Code:
mahmood@pc:~$ l a/
1.txt  2.txt  3.txt  b/
mahmood@pc:~$ tar cvjf compressed.tar.bz2 --exclude=/home/mahmood/a/b/ a/
a/
a/2.txt
a/1.txt
a/3.txt
a/b/
mahmood@pc:~$
As you can see although I excluded b/ but tar command ignored that. any idea about that?
 
Old 07-06-2011, 03:07 PM   #2
colucix
Moderator
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957
In your command the pattern /home/mahmood/a/b/ is not matched by a/b, unless you give the full path to the directory you want to archive:
Code:
tar cvjf compressed.tar.bz2 --exclude=/home/mahmood/a/b /home/mahmood/a
or using the relative path:
Code:
tar cvjf compressed.tar.bz2 --exclude=a/b a
Also notes that the trailing slash at the end of the exclude pattern does not work. I cannot explain exactly this behavior, anyway.
 
Old 07-07-2011, 02:23 AM   #3
mahmoodn
Member
 
Registered: May 2010
Posts: 403

Original Poster
Rep: Reputation: 16
Yes thanks a lot. it works
 
  


Reply

Tags
--exclude, ignore, tar


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 On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] tar with --exclude and/or --exclude-from vbekker Linux - Newbie 6 12-09-2010 03:51 AM
CVS Exclude : Exclude sub directories from check out On Linux from command line shajay12 Linux - Newbie 1 08-03-2009 01:36 AM
tar --exclude-from=files command not working cucolin@ Linux - Server 2 04-03-2007 10:33 PM
tar --exclude --exclude-from cefn Linux - Software 4 10-11-2005 08:31 PM
Large backups or Tar doesn't work jeanpba Linux - Hardware 1 10-04-2002 11:04 AM


All times are GMT -5. The time now is 07:16 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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration