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 07-27-2012, 10:48 AM   #1
lleb
Senior Member
 
Registered: Dec 2005
Location: Florida
Distribution: CentOS/Fedora
Posts: 2,630

Rep: Reputation: 495Reputation: 495Reputation: 495Reputation: 495Reputation: 495
issue with tar and -X option


hello, playing around with the -X in tar to point to my excludes.conf file, but the problem is tar is reading everything past the tar cvjf as the foo.tar.bz2 file and NOT reading the -X. have also tried --exclude-from=excludes.conf this was even worse.

Code:
tar cvjf -X /path/to/excludes.conf FOO.tar.bz2 /path/to/directory/to/tar/
This produces a tarfile labeled -X and does nothing with the excludes. so i tried:

Code:
tar cjvf --exclude-from=/path/to/excludes.conf FOO.tar.bz2 /path/to/directory/to/tar/
this made the tarfile --excludes-from=/path/to/excludes\ FOO.tar.bz2

again not what I want.

What is the proper syntax that I am missing....

here is what I read

Quote:
‘--exclude-from=file’
‘-X file’
Causes tar to ignore files that match the patterns listed in file.

Use the ‘--exclude-from’ option to read a list of patterns, one per line, from file; tar will ignore files matching those patterns. Thus if tar is called as ‘tar -c -X foo .’ and the file ‘foo’ contains a single line ‘*.o’, no files whose names end in ‘.o’ will be added to the archive.

Notice, that lines from file are read verbatim. One of the frequent errors is leaving some extra whitespace after a file name, which is difficult to catch using text editors.

However, empty lines are OK.
the -X option does not give me the option of a path to create and a path to create from for the tarball.
 
Old 07-27-2012, 10:55 AM   #2
roger_heslop
Member
 
Registered: Oct 2009
Location: Leander, TX
Distribution: Fedora 20
Posts: 97

Rep: Reputation: 35
The -X switch should probably not come immediately after -f. The -f switch specifies the file, and immediately following the that would be the name of the file which you would like, which explains the outcome.

Try this: tar cjvf FOO.tar.bz2 --exclude-from=/path/to/excludes.conf /path/to/directory/to/tar/

...or some other variant.

Last edited by roger_heslop; 07-27-2012 at 11:03 AM.
 
3 members found this post helpful.
Old 07-27-2012, 11:39 AM   #3
lleb
Senior Member
 
Registered: Dec 2005
Location: Florida
Distribution: CentOS/Fedora
Posts: 2,630

Original Poster
Rep: Reputation: 495Reputation: 495Reputation: 495Reputation: 495Reputation: 495
thank you roger_heslop, i was just getting ready to report i figured it out. i had the syntax wrong. needed exactly like you posted the -X or --exclude-from=FOO needs to be after the file name to tar.
 
Old 07-27-2012, 12:14 PM   #4
TobiSGD
Moderator
 
Registered: Dec 2009
Location: Germany
Distribution: Whatever fits the task best
Posts: 17,131
Blog Entries: 2

Rep: Reputation: 4833Reputation: 4833Reputation: 4833Reputation: 4833Reputation: 4833Reputation: 4833Reputation: 4833Reputation: 4833Reputation: 4833Reputation: 4833Reputation: 4833
Quote:
Originally Posted by lleb View Post
thank you roger_heslop, i was just getting ready to report i figured it out. i had the syntax wrong. needed exactly like you posted the -X or --exclude-from=FOO needs to be after the file name to tar.
That is not really true. Your issue was not that it came before the filename, but between the -f option and the filename.
Code:
tar cvjf filename files-to-tar
is nothing more than the short form for
Code:
tar -c -v -j -f filename files-to-tar
In the long form it seems to be more clear that filename is a parameter for the -f option. So it is perfectly valid to
put the -X option before the filename, but just not between the -f option and its parameter, the filename.
For example, these are valid ways to do it:
Code:
tar -X excludefile -c -v -j -f filename files-to-tar
tar -X excludefile cvjf filename files-to-tar
tar cvjX excludefile -f filename files-to-tar
tar cvjf filename -X excludefile files-to-tar
tar cvjf filename files-to-tar -X excludefile
In short, the -f option, in all its allowed forms, always expects a filename after it, in the same way that the -X option always expects the excludefile after it.
 
2 members found this post helpful.
Old 07-27-2012, 12:39 PM   #5
lleb
Senior Member
 
Registered: Dec 2005
Location: Florida
Distribution: CentOS/Fedora
Posts: 2,630

Original Poster
Rep: Reputation: 495Reputation: 495Reputation: 495Reputation: 495Reputation: 495
TobiSGD Thank you, that is much more clear.
 
  


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
backup: tar with the -L option help Paxmaster Linux - Software 1 11-18-2005 08:06 PM
tar option Paxmaster Linux - Software 1 11-16-2005 07:27 AM
tar -C option ? shanenin Linux - Software 3 07-25-2004 10:36 PM
tar command include option? x5452 Linux - General 7 05-20-2004 11:18 PM
tar bzip2 and the -y option mark33andathird Linux - General 1 04-30-2002 01:22 PM


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