Exclude files except a specific on in tar
Clash Royale CLAN TAG#URR8PPP
up vote
0
down vote
favorite
I want to make a tarball of a directory, but excluding all files that end with .foo
, except for one specific file. This excludes all files with .foo
as ending:
tar czf "$nameTarball" dir/ --exclude '*.foo'
What I'm missing is some sort of --include
option. Does it exist?
I'm using GNU tar 1.23.
tar
add a comment |Â
up vote
0
down vote
favorite
I want to make a tarball of a directory, but excluding all files that end with .foo
, except for one specific file. This excludes all files with .foo
as ending:
tar czf "$nameTarball" dir/ --exclude '*.foo'
What I'm missing is some sort of --include
option. Does it exist?
I'm using GNU tar 1.23.
tar
add a comment |Â
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I want to make a tarball of a directory, but excluding all files that end with .foo
, except for one specific file. This excludes all files with .foo
as ending:
tar czf "$nameTarball" dir/ --exclude '*.foo'
What I'm missing is some sort of --include
option. Does it exist?
I'm using GNU tar 1.23.
tar
I want to make a tarball of a directory, but excluding all files that end with .foo
, except for one specific file. This excludes all files with .foo
as ending:
tar czf "$nameTarball" dir/ --exclude '*.foo'
What I'm missing is some sort of --include
option. Does it exist?
I'm using GNU tar 1.23.
tar
tar
edited Aug 31 at 14:24
Jeff Schaller
32.8k849110
32.8k849110
asked Aug 31 at 12:23
pfnuesel
2,60541838
2,60541838
add a comment |Â
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
1
down vote
accepted
There is no --include
-style option in GNU tar
as far as IâÂÂm aware.
In GNU tar
, later versions (starting with 1.29) treat --exclude
and other filename-selection options in a position-sensitive fashion, so they only affects arguments after them on the command line. So you can include files by naming them before the --exclude
option:
tar czf "$nameTarball" dir/specific.foo --exclude '*.foo' dir/
I installed a newer version of tar and it works now. Thanks! (I wonder why certain distros use tar that is from 2010!)
â pfnuesel
Aug 31 at 13:34
A typicaltar
implementation that is part of an operating system distro supports-I
. This has been added to BSD tar (not bsdtar) in the late 1980s. But If a filename is in the-X
file as well, itis excluded. Note that--exclude
is a non-portable vendor unique GNU tar extension.
â schily
Aug 31 at 13:59
@schily GNUtar
supports both-T
(equivalent to BSDâÂÂs-I
, where-T
also works) and-X
, but as you imply theyâÂÂre not helpful in this situation since the exclusions given by-X
have greater precedence than the files given by-T
.
â Stephen Kitt
Aug 31 at 14:31
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
accepted
There is no --include
-style option in GNU tar
as far as IâÂÂm aware.
In GNU tar
, later versions (starting with 1.29) treat --exclude
and other filename-selection options in a position-sensitive fashion, so they only affects arguments after them on the command line. So you can include files by naming them before the --exclude
option:
tar czf "$nameTarball" dir/specific.foo --exclude '*.foo' dir/
I installed a newer version of tar and it works now. Thanks! (I wonder why certain distros use tar that is from 2010!)
â pfnuesel
Aug 31 at 13:34
A typicaltar
implementation that is part of an operating system distro supports-I
. This has been added to BSD tar (not bsdtar) in the late 1980s. But If a filename is in the-X
file as well, itis excluded. Note that--exclude
is a non-portable vendor unique GNU tar extension.
â schily
Aug 31 at 13:59
@schily GNUtar
supports both-T
(equivalent to BSDâÂÂs-I
, where-T
also works) and-X
, but as you imply theyâÂÂre not helpful in this situation since the exclusions given by-X
have greater precedence than the files given by-T
.
â Stephen Kitt
Aug 31 at 14:31
add a comment |Â
up vote
1
down vote
accepted
There is no --include
-style option in GNU tar
as far as IâÂÂm aware.
In GNU tar
, later versions (starting with 1.29) treat --exclude
and other filename-selection options in a position-sensitive fashion, so they only affects arguments after them on the command line. So you can include files by naming them before the --exclude
option:
tar czf "$nameTarball" dir/specific.foo --exclude '*.foo' dir/
I installed a newer version of tar and it works now. Thanks! (I wonder why certain distros use tar that is from 2010!)
â pfnuesel
Aug 31 at 13:34
A typicaltar
implementation that is part of an operating system distro supports-I
. This has been added to BSD tar (not bsdtar) in the late 1980s. But If a filename is in the-X
file as well, itis excluded. Note that--exclude
is a non-portable vendor unique GNU tar extension.
â schily
Aug 31 at 13:59
@schily GNUtar
supports both-T
(equivalent to BSDâÂÂs-I
, where-T
also works) and-X
, but as you imply theyâÂÂre not helpful in this situation since the exclusions given by-X
have greater precedence than the files given by-T
.
â Stephen Kitt
Aug 31 at 14:31
add a comment |Â
up vote
1
down vote
accepted
up vote
1
down vote
accepted
There is no --include
-style option in GNU tar
as far as IâÂÂm aware.
In GNU tar
, later versions (starting with 1.29) treat --exclude
and other filename-selection options in a position-sensitive fashion, so they only affects arguments after them on the command line. So you can include files by naming them before the --exclude
option:
tar czf "$nameTarball" dir/specific.foo --exclude '*.foo' dir/
There is no --include
-style option in GNU tar
as far as IâÂÂm aware.
In GNU tar
, later versions (starting with 1.29) treat --exclude
and other filename-selection options in a position-sensitive fashion, so they only affects arguments after them on the command line. So you can include files by naming them before the --exclude
option:
tar czf "$nameTarball" dir/specific.foo --exclude '*.foo' dir/
edited Aug 31 at 14:29
answered Aug 31 at 12:41
Stephen Kitt
147k22321388
147k22321388
I installed a newer version of tar and it works now. Thanks! (I wonder why certain distros use tar that is from 2010!)
â pfnuesel
Aug 31 at 13:34
A typicaltar
implementation that is part of an operating system distro supports-I
. This has been added to BSD tar (not bsdtar) in the late 1980s. But If a filename is in the-X
file as well, itis excluded. Note that--exclude
is a non-portable vendor unique GNU tar extension.
â schily
Aug 31 at 13:59
@schily GNUtar
supports both-T
(equivalent to BSDâÂÂs-I
, where-T
also works) and-X
, but as you imply theyâÂÂre not helpful in this situation since the exclusions given by-X
have greater precedence than the files given by-T
.
â Stephen Kitt
Aug 31 at 14:31
add a comment |Â
I installed a newer version of tar and it works now. Thanks! (I wonder why certain distros use tar that is from 2010!)
â pfnuesel
Aug 31 at 13:34
A typicaltar
implementation that is part of an operating system distro supports-I
. This has been added to BSD tar (not bsdtar) in the late 1980s. But If a filename is in the-X
file as well, itis excluded. Note that--exclude
is a non-portable vendor unique GNU tar extension.
â schily
Aug 31 at 13:59
@schily GNUtar
supports both-T
(equivalent to BSDâÂÂs-I
, where-T
also works) and-X
, but as you imply theyâÂÂre not helpful in this situation since the exclusions given by-X
have greater precedence than the files given by-T
.
â Stephen Kitt
Aug 31 at 14:31
I installed a newer version of tar and it works now. Thanks! (I wonder why certain distros use tar that is from 2010!)
â pfnuesel
Aug 31 at 13:34
I installed a newer version of tar and it works now. Thanks! (I wonder why certain distros use tar that is from 2010!)
â pfnuesel
Aug 31 at 13:34
A typical
tar
implementation that is part of an operating system distro supports -I
. This has been added to BSD tar (not bsdtar) in the late 1980s. But If a filename is in the -X
file as well, itis excluded. Note that --exclude
is a non-portable vendor unique GNU tar extension.â schily
Aug 31 at 13:59
A typical
tar
implementation that is part of an operating system distro supports -I
. This has been added to BSD tar (not bsdtar) in the late 1980s. But If a filename is in the -X
file as well, itis excluded. Note that --exclude
is a non-portable vendor unique GNU tar extension.â schily
Aug 31 at 13:59
@schily GNU
tar
supports both -T
(equivalent to BSDâÂÂs -I
, where -T
also works) and -X
, but as you imply theyâÂÂre not helpful in this situation since the exclusions given by -X
have greater precedence than the files given by -T
.â Stephen Kitt
Aug 31 at 14:31
@schily GNU
tar
supports both -T
(equivalent to BSDâÂÂs -I
, where -T
also works) and -X
, but as you imply theyâÂÂre not helpful in this situation since the exclusions given by -X
have greater precedence than the files given by -T
.â Stephen Kitt
Aug 31 at 14:31
add a comment |Â
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%2f466023%2fexclude-files-except-a-specific-on-in-tar%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