1
find /home/karl/dev/beer/ -printf "%P\n" | tar --exclude='./.git' -czf beer.tgz --no-recursion -C /home/karl/dev/beer/ -T -

The command still includes the .git directory.

2
  • did you fix it?
    – Zanna
    Apr 25, 2017 at 14:06
  • @Zanna Nope! Not yet! Apr 26, 2017 at 9:57

2 Answers 2

0

You can try to exclude the directory in find like this:

find /home/karl/dev/beer -path .git -prune -printf "%P\n" | tar -czf beer.tar.gz --no-recursion  -T -

You can check also this discussion.

2
  • No files are added now :( Apr 22, 2017 at 18:48
  • Try to remove also the printf command in find. I am not sure you need it Apr 22, 2017 at 18:49
0

from man find:

 -printf
 ....
 %P     File's name with the name of the starting-point under which it was found 
        removed.

So you are excluding a directory that doesn't exist in your output. If you look at the output of your find command before you pipe it (generally a good idea), you will see it has no leading ./. So, you should use --exclude='.git' not ./.git

But rather than using find for this, you might want to use globstar to make globbing recursive:

shopt -s globstar
tar --exclude='.git' -czvf beer.tar.gz /home/karl/dev/beer/**

Not the answer you're looking for? Browse other questions tagged .