[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: A simple question about wildcards with tar



On Wed, Oct 03, 2001 at 01:57:58PM -0700, Walter Landry wrote:
> I'm trying to make a backup with tar, but there are certain files that
> I don't want to include in the backup.  Reading the info documentation
> about tar, it says that I can use the --exclude=PATTERN option.  So if
> I type
> 
>   tar -cvf backup.tar --exclude='*.fig' *
> 
> then it excludes all files that end with .fig.  However, if I also
> want to exclude files that end with .fig.bak, then it
> seems that
> 
>   tar -cvf backup.tar --exclude='*.fig*' *
> 
> should work.  But it doesn't.

Are you by any chance using a version of libc6 less than 2.1.96-1? See
bug #59829 for the gory details. The summary was:

  tar checks whether a name is excluded by using the libc function
  fnmatch() with FNM_FILE_NAME and FNM_LEADING_DIR. With these flags, a
  pattern like "_*" matches a string that contains something matching "_*"
  and containing no slashes, followed by a string containing exactly one
  slash: that is, the pattern is matched against everything but the final
  component of the file name and the preceding slash. "*" will match
  "foo/bar", but not "foo" or "foo/bar/baz", using these flags - despite
  the fact that the pattern "foo" will match all three of these strings
  using these flags. This causes tar a good deal of confusion.

This was (eventually) fixed in glibc upstream. Unfortunately, I don't
know of a workaround other than upgrading libc6, using another tool for
now, or generating the list of files in some other way.

-- 
Colin Watson                                  [cjwatson@flatline.org.uk]



Reply to: