Tar version:
root@node: /tmp > tar --version
bsdtar 3.4.2 - libarchive 3.4.2 zlib/1.2.11 liblzma/5.2.5 bz2lib/1.0.8
I have a directory structure which looks like this:
root@node: /tmp > ls -lrth main
total 8
drwxr-xr-x 2 root wheel 512B Jun 26 00:02 b
-rw-r--r-- 1 root wheel 0B Jun 26 00:02 c.txt
lrwxr-xr-x 1 root wheel 11B Jun 26 00:02 a -> /tmp/main/b
When I use --exclude
on a
, I would want b
to be excluded as well, but that's not happening. May I know what I could be missing?
I have tried following commands:
root@node : /tmp > tar --exclude /tmp/main/a -zcvf /tmp/test.tar.gz /tmp/main
tar: Removing leading '/' from member names
a tmp/main
a tmp/main/b
a tmp/main/c.txt
root@node : /tmp > tar tf /tmp/test.tar.gz
tmp/main/
tmp/main/b/
tmp/main/c.txt
Also tried using the --dereference
option, but no luck:
root@node : /tmp > tar --dereference --exclude /tmp/main/a -zcvf /tmp/test.tar.gz /tmp/main
tar: Removing leading '/' from member names
a tmp/main
a tmp/main/b
a tmp/main/c.txt
root@node : /tmp > tar tf /tmp/test.tar.gz
tmp/main/
tmp/main/b/
tmp/main/c.txt
b
... Are you expectingtar
to read the target of the excluded symbolic link and assume that this should be excluded too?