Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back > Forums > Linux Forums > Linux - Software
User Name
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.


  Search this Thread
Old 02-15-2004, 05:25 PM   #1
Registered: Aug 2003
Location: Victoria, Texas
Distribution: Gentoo
Posts: 63

Rep: Reputation: 15
tar question

What is the correct usage of the -X (exclude files from a backup) qualifier with the tar command? I would like to tar a directory that contains several subdirectories. There are many files I would like to exclude from several subdirectories in the backup. They are common in the fact that they have a common extension name.

tar -cvf mozilla .tar /home/user/.mozilla/user/jcx21zrd.slt/Mail

would include all the files in /Mail and its subdirectories, right?

How do I qaulifiy the tar command to exclude *.msf files in several different subdiretories in the backup?

Old 02-15-2004, 06:58 PM   #2
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910
find /home/user/.mozilla/user/jcx21zrd.slt/ -iname "*.msf" > ~/exclusion.txt
tar -X ~/exclusion.txt -cvf mozilla .tar /home/user/.mozilla/user/jcx21zrd.slt/Mail

Old 02-15-2004, 07:04 PM   #3
Senior Member
Registered: Oct 2003
Posts: 3,057

Rep: Reputation: 59
If I understand the man page correctly, the ( -X ) reads the file names from a list where ( file ) is the name of that list. That's not the way I do it.....

For example, to not tar any files with the html extension in my home directory and save that tar file to the /mnt directory, I would cd to the home directory and use this command.....
tar --exclude="*.html" -cvzf /mnt/test.tar.gz .

If you don't want to use the ( . ) to indicate ( present directory ) you can type out the path like this.....
tar --exclude="*.html" -cvzf /mnt/test.tar.gz /home/*

I think the tar --help explains that somewhat better than man tar
Old 02-16-2004, 05:39 PM   #4
Registered: Aug 2003
Location: Victoria, Texas
Distribution: Gentoo
Posts: 63

Original Poster
Rep: Reputation: 15
Thanks to all. I ended up using the tar --exclude"" format as it was quicker.

Once again, though, a kind soul has shown me the power of the "find" command. Thanks very much!


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
how can i decompress this tar.tar file? hmmm sounds new.. tar.tar.. help ;) kublador Linux - Software 14 10-25-2016 02:48 AM
tar tar cvf - . | (cd /root/; tar xvf -) ewt3y Linux - General 10 02-19-2014 10:55 AM
a tough question 4 u, problem in extracting tar & tar.gz files p_garg Linux - General 5 11-08-2010 11:02 AM
Diferance between rpm, tar, tar.gz, scr.tar, etc mobassir Linux - General 12 08-21-2003 06:30 AM
tar.gz question <---NOOOOOB QUESTION jairo Linux - Software 4 02-17-2003 05:28 AM > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 10:26 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration