Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I keep a list of photos burned to dvds for incremental backups but I got into a strange situation where a file was already burned into a dvd but tar keeps saying it's not. Here the steps to reproduce:

mkdir tarbug && cd tarbug
mkdir -p photos/{1,2,3}
touch "photos/1/P06-23-08_15.21[1].jpg"
touch "photos/2/P06.jpg"
touch "photos/3/P01.jpg"

Create a list of all files (normally I append to list once a dvd is burned):

find photos -type f > list

Now give me new files excluding files in list and don't show directories:

tar cf - photos -X list | tar tf - | grep -v '/$'



That shouldn't show as it's in the file list. I figured out it's brackets that need to be escaped by backslash? but how I'm supposed to know that? any list of characters tar doesn't like or uses for something else?

share|improve this question
up vote 7 down vote accepted

If you look at tar's manpage, you'll see:

 -X, --exclude-from FILE
       exclude patterns listed in FILE

The info doc gives further details.

So list needs to be a list of patterns, not file names. A pattern, as normal, means a shell wildcard pattern. So, at minimum, *, [], and ] are special. Possibly { and } as well.

The documentation also mentions you can change this by passing --no-wildcards. Then the names will be matched literally, not as patterns. --no-wildcards needs to go before the -X.

[This is GNU tar I checked. Other tar implementations probably differ.]

share|improve this answer
+1 for special characters but --no-wildcards does not work on GNU tar – vimdude Sep 25 '13 at 16:17
nm. order of argument is important, if you put --no-wildcards before -X ... it works but if you put it after -X ... it doesn't. – vimdude Sep 25 '13 at 16:24
@abdelsaid Ah, that's important. I'll add it to the answer to make sure anyone else stumbling across this question sees it. – derobert Sep 25 '13 at 16:25

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.