With bsdtar â--excludeâ, how to only exclude subdirectories?
Clash Royale CLAN TAG#URR8PPP
up vote
2
down vote
favorite
In GNU tar (i.e. gtar
), the --exclude
option with a glob only matches the subdirectories, but not the directory itself. For example, --exclude test-tar/a/b/*
would exclude anything inside of b
, but not b
itself. However, bsdtar
is excluding the directory itself as well. My question is how do I make bsdtar
act the same as GNU in this regard?
Here is an example script the demonstrates the problem:
#!/usr/bin/env bash
echo -e "nGiven an archive that looks like this:"
bsdtar -tf test.tgz
echo -e "nExtract the archive excluding test-tar/a/b/* using gtar"
rm -rf test-tar
gtar -xzf test.tgz --exclude 'test-tar/a/b/*'
file test-tar/a/b
file test-tar/a/b/B.txt
echo -e "nExtract the archive excluding test-tar/a/b/* using bsdtar"
rm -rf test-tar
bsdtar -xzf test.tgz --exclude 'test-tar/a/b/*'
file test-tar/a/b
file test-tar/a/b/B.txt
This outputs:
Given an archive that looks like this:
test-tar/
test-tar/a/
test-tar/a/A.txt
test-tar/a/b/
test-tar/a/b/B.txt
Extract the archive excluding test-tar/a/b/* using gtar
test-tar/a/b: directory
test-tar/a/b/B.txt: cannot open `test-tar/a/b/B.txt' (No such file or directory)
Extract the archive excluding test-tar/a/b/* using bsdtar
test-tar/a/b: cannot open `test-tar/a/b' (No such file or directory)
test-tar/a/b/B.txt: cannot open `test-tar/a/b/B.txt' (No such file or directory)
My versions are tar (GNU tar) 1.29
and bsdtar 3.3.2
.
tar gnu bsd
add a comment |Â
up vote
2
down vote
favorite
In GNU tar (i.e. gtar
), the --exclude
option with a glob only matches the subdirectories, but not the directory itself. For example, --exclude test-tar/a/b/*
would exclude anything inside of b
, but not b
itself. However, bsdtar
is excluding the directory itself as well. My question is how do I make bsdtar
act the same as GNU in this regard?
Here is an example script the demonstrates the problem:
#!/usr/bin/env bash
echo -e "nGiven an archive that looks like this:"
bsdtar -tf test.tgz
echo -e "nExtract the archive excluding test-tar/a/b/* using gtar"
rm -rf test-tar
gtar -xzf test.tgz --exclude 'test-tar/a/b/*'
file test-tar/a/b
file test-tar/a/b/B.txt
echo -e "nExtract the archive excluding test-tar/a/b/* using bsdtar"
rm -rf test-tar
bsdtar -xzf test.tgz --exclude 'test-tar/a/b/*'
file test-tar/a/b
file test-tar/a/b/B.txt
This outputs:
Given an archive that looks like this:
test-tar/
test-tar/a/
test-tar/a/A.txt
test-tar/a/b/
test-tar/a/b/B.txt
Extract the archive excluding test-tar/a/b/* using gtar
test-tar/a/b: directory
test-tar/a/b/B.txt: cannot open `test-tar/a/b/B.txt' (No such file or directory)
Extract the archive excluding test-tar/a/b/* using bsdtar
test-tar/a/b: cannot open `test-tar/a/b' (No such file or directory)
test-tar/a/b/B.txt: cannot open `test-tar/a/b/B.txt' (No such file or directory)
My versions are tar (GNU tar) 1.29
and bsdtar 3.3.2
.
tar gnu bsd
add a comment |Â
up vote
2
down vote
favorite
up vote
2
down vote
favorite
In GNU tar (i.e. gtar
), the --exclude
option with a glob only matches the subdirectories, but not the directory itself. For example, --exclude test-tar/a/b/*
would exclude anything inside of b
, but not b
itself. However, bsdtar
is excluding the directory itself as well. My question is how do I make bsdtar
act the same as GNU in this regard?
Here is an example script the demonstrates the problem:
#!/usr/bin/env bash
echo -e "nGiven an archive that looks like this:"
bsdtar -tf test.tgz
echo -e "nExtract the archive excluding test-tar/a/b/* using gtar"
rm -rf test-tar
gtar -xzf test.tgz --exclude 'test-tar/a/b/*'
file test-tar/a/b
file test-tar/a/b/B.txt
echo -e "nExtract the archive excluding test-tar/a/b/* using bsdtar"
rm -rf test-tar
bsdtar -xzf test.tgz --exclude 'test-tar/a/b/*'
file test-tar/a/b
file test-tar/a/b/B.txt
This outputs:
Given an archive that looks like this:
test-tar/
test-tar/a/
test-tar/a/A.txt
test-tar/a/b/
test-tar/a/b/B.txt
Extract the archive excluding test-tar/a/b/* using gtar
test-tar/a/b: directory
test-tar/a/b/B.txt: cannot open `test-tar/a/b/B.txt' (No such file or directory)
Extract the archive excluding test-tar/a/b/* using bsdtar
test-tar/a/b: cannot open `test-tar/a/b' (No such file or directory)
test-tar/a/b/B.txt: cannot open `test-tar/a/b/B.txt' (No such file or directory)
My versions are tar (GNU tar) 1.29
and bsdtar 3.3.2
.
tar gnu bsd
In GNU tar (i.e. gtar
), the --exclude
option with a glob only matches the subdirectories, but not the directory itself. For example, --exclude test-tar/a/b/*
would exclude anything inside of b
, but not b
itself. However, bsdtar
is excluding the directory itself as well. My question is how do I make bsdtar
act the same as GNU in this regard?
Here is an example script the demonstrates the problem:
#!/usr/bin/env bash
echo -e "nGiven an archive that looks like this:"
bsdtar -tf test.tgz
echo -e "nExtract the archive excluding test-tar/a/b/* using gtar"
rm -rf test-tar
gtar -xzf test.tgz --exclude 'test-tar/a/b/*'
file test-tar/a/b
file test-tar/a/b/B.txt
echo -e "nExtract the archive excluding test-tar/a/b/* using bsdtar"
rm -rf test-tar
bsdtar -xzf test.tgz --exclude 'test-tar/a/b/*'
file test-tar/a/b
file test-tar/a/b/B.txt
This outputs:
Given an archive that looks like this:
test-tar/
test-tar/a/
test-tar/a/A.txt
test-tar/a/b/
test-tar/a/b/B.txt
Extract the archive excluding test-tar/a/b/* using gtar
test-tar/a/b: directory
test-tar/a/b/B.txt: cannot open `test-tar/a/b/B.txt' (No such file or directory)
Extract the archive excluding test-tar/a/b/* using bsdtar
test-tar/a/b: cannot open `test-tar/a/b' (No such file or directory)
test-tar/a/b/B.txt: cannot open `test-tar/a/b/B.txt' (No such file or directory)
My versions are tar (GNU tar) 1.29
and bsdtar 3.3.2
.
tar gnu bsd
edited Jul 24 at 16:23
Volker Siegel
10.2k33058
10.2k33058
asked Nov 29 '17 at 8:45
ryanbrainard
1264
1264
add a comment |Â
add a comment |Â
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f407679%2fwith-bsdtar-exclude-how-to-only-exclude-subdirectories%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password