Make tar archive in parent directory
Clash Royale CLAN TAG#URR8PPP
up vote
-1
down vote
favorite
I am currently trying to bundle certain files in my current directory into a tar archive, and then make it so the archive is in the parent of my current directory. I'm wondering if anyone could explain to me how to do this. I understand how to bundle the files I need, but I am confused as to how I can make it so the archive is in the parent.
Currently I am using the command:
$ tar -tvf something.tar $( find -name "*.txt")
as I need to bundle files with the .txt extension.
shell tar
add a comment |Â
up vote
-1
down vote
favorite
I am currently trying to bundle certain files in my current directory into a tar archive, and then make it so the archive is in the parent of my current directory. I'm wondering if anyone could explain to me how to do this. I understand how to bundle the files I need, but I am confused as to how I can make it so the archive is in the parent.
Currently I am using the command:
$ tar -tvf something.tar $( find -name "*.txt")
as I need to bundle files with the .txt extension.
shell tar
1
By the way, the question and answer assume GNU findutils is used, because it omits the (POSIX-required) parameter before-name
.
â Thomas Dickey
Sep 11 at 1:03
@ThomasDickey I'm going to assume that the command worked as the answer was accepted (it also worked in the environment where I tested) but I went ahead and added thefind
command with the parameters before-name
at the end of my answer as you've made a good point.
â Nasir Riley
Sep 11 at 12:05
add a comment |Â
up vote
-1
down vote
favorite
up vote
-1
down vote
favorite
I am currently trying to bundle certain files in my current directory into a tar archive, and then make it so the archive is in the parent of my current directory. I'm wondering if anyone could explain to me how to do this. I understand how to bundle the files I need, but I am confused as to how I can make it so the archive is in the parent.
Currently I am using the command:
$ tar -tvf something.tar $( find -name "*.txt")
as I need to bundle files with the .txt extension.
shell tar
I am currently trying to bundle certain files in my current directory into a tar archive, and then make it so the archive is in the parent of my current directory. I'm wondering if anyone could explain to me how to do this. I understand how to bundle the files I need, but I am confused as to how I can make it so the archive is in the parent.
Currently I am using the command:
$ tar -tvf something.tar $( find -name "*.txt")
as I need to bundle files with the .txt extension.
shell tar
shell tar
edited Sep 11 at 0:51
slmâ¦
239k65494665
239k65494665
asked Sep 11 at 0:14
Anthony Rulli
83
83
1
By the way, the question and answer assume GNU findutils is used, because it omits the (POSIX-required) parameter before-name
.
â Thomas Dickey
Sep 11 at 1:03
@ThomasDickey I'm going to assume that the command worked as the answer was accepted (it also worked in the environment where I tested) but I went ahead and added thefind
command with the parameters before-name
at the end of my answer as you've made a good point.
â Nasir Riley
Sep 11 at 12:05
add a comment |Â
1
By the way, the question and answer assume GNU findutils is used, because it omits the (POSIX-required) parameter before-name
.
â Thomas Dickey
Sep 11 at 1:03
@ThomasDickey I'm going to assume that the command worked as the answer was accepted (it also worked in the environment where I tested) but I went ahead and added thefind
command with the parameters before-name
at the end of my answer as you've made a good point.
â Nasir Riley
Sep 11 at 12:05
1
1
By the way, the question and answer assume GNU findutils is used, because it omits the (POSIX-required) parameter before
-name
.â Thomas Dickey
Sep 11 at 1:03
By the way, the question and answer assume GNU findutils is used, because it omits the (POSIX-required) parameter before
-name
.â Thomas Dickey
Sep 11 at 1:03
@ThomasDickey I'm going to assume that the command worked as the answer was accepted (it also worked in the environment where I tested) but I went ahead and added the
find
command with the parameters before -name
at the end of my answer as you've made a good point.â Nasir Riley
Sep 11 at 12:05
@ThomasDickey I'm going to assume that the command worked as the answer was accepted (it also worked in the environment where I tested) but I went ahead and added the
find
command with the parameters before -name
at the end of my answer as you've made a good point.â Nasir Riley
Sep 11 at 12:05
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
2
down vote
accepted
You can do it one of a few ways:
tar cvf ../something.tar $( find -name "*.txt")
That will make it so that the files are put into something.tar
in the directory right above.
A more long-winded way is this:
tar cvf /path/to/something.tar $( find -name "*.txt")
That uses the direct path to where you want to put the .tar
file.
If you want actual compression:
tar cvfz something.tar.gz $( find -name "*.txt")
The z
will put it into a .gz
archive.
Basically, you want to use cvf
or cfvz
as the c
will compress the contents into an actual archive. Using t
as in your tvf
command is to send the contents of the archive to standard output without extracting it which won't work as you haven't creating the .tar
archive yet.
You may also need to escape the *
depending on your environment:
tar cvf ../something.tar $( find -name "*.txt")
Another update for anyone who may need this in the future:
For anyone else who wants to use this, if you don't have findutils
installed, it will be necessary to include the path that you are searching before -name
in the find command:
tar cvf ../something.tar $( find . -name "*.txt")
tar cvf ../something.tar $( find /path/to/directory -name "*.txt")
The first searches in the current directory and the second searches using the path to the directory.
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
2
down vote
accepted
You can do it one of a few ways:
tar cvf ../something.tar $( find -name "*.txt")
That will make it so that the files are put into something.tar
in the directory right above.
A more long-winded way is this:
tar cvf /path/to/something.tar $( find -name "*.txt")
That uses the direct path to where you want to put the .tar
file.
If you want actual compression:
tar cvfz something.tar.gz $( find -name "*.txt")
The z
will put it into a .gz
archive.
Basically, you want to use cvf
or cfvz
as the c
will compress the contents into an actual archive. Using t
as in your tvf
command is to send the contents of the archive to standard output without extracting it which won't work as you haven't creating the .tar
archive yet.
You may also need to escape the *
depending on your environment:
tar cvf ../something.tar $( find -name "*.txt")
Another update for anyone who may need this in the future:
For anyone else who wants to use this, if you don't have findutils
installed, it will be necessary to include the path that you are searching before -name
in the find command:
tar cvf ../something.tar $( find . -name "*.txt")
tar cvf ../something.tar $( find /path/to/directory -name "*.txt")
The first searches in the current directory and the second searches using the path to the directory.
add a comment |Â
up vote
2
down vote
accepted
You can do it one of a few ways:
tar cvf ../something.tar $( find -name "*.txt")
That will make it so that the files are put into something.tar
in the directory right above.
A more long-winded way is this:
tar cvf /path/to/something.tar $( find -name "*.txt")
That uses the direct path to where you want to put the .tar
file.
If you want actual compression:
tar cvfz something.tar.gz $( find -name "*.txt")
The z
will put it into a .gz
archive.
Basically, you want to use cvf
or cfvz
as the c
will compress the contents into an actual archive. Using t
as in your tvf
command is to send the contents of the archive to standard output without extracting it which won't work as you haven't creating the .tar
archive yet.
You may also need to escape the *
depending on your environment:
tar cvf ../something.tar $( find -name "*.txt")
Another update for anyone who may need this in the future:
For anyone else who wants to use this, if you don't have findutils
installed, it will be necessary to include the path that you are searching before -name
in the find command:
tar cvf ../something.tar $( find . -name "*.txt")
tar cvf ../something.tar $( find /path/to/directory -name "*.txt")
The first searches in the current directory and the second searches using the path to the directory.
add a comment |Â
up vote
2
down vote
accepted
up vote
2
down vote
accepted
You can do it one of a few ways:
tar cvf ../something.tar $( find -name "*.txt")
That will make it so that the files are put into something.tar
in the directory right above.
A more long-winded way is this:
tar cvf /path/to/something.tar $( find -name "*.txt")
That uses the direct path to where you want to put the .tar
file.
If you want actual compression:
tar cvfz something.tar.gz $( find -name "*.txt")
The z
will put it into a .gz
archive.
Basically, you want to use cvf
or cfvz
as the c
will compress the contents into an actual archive. Using t
as in your tvf
command is to send the contents of the archive to standard output without extracting it which won't work as you haven't creating the .tar
archive yet.
You may also need to escape the *
depending on your environment:
tar cvf ../something.tar $( find -name "*.txt")
Another update for anyone who may need this in the future:
For anyone else who wants to use this, if you don't have findutils
installed, it will be necessary to include the path that you are searching before -name
in the find command:
tar cvf ../something.tar $( find . -name "*.txt")
tar cvf ../something.tar $( find /path/to/directory -name "*.txt")
The first searches in the current directory and the second searches using the path to the directory.
You can do it one of a few ways:
tar cvf ../something.tar $( find -name "*.txt")
That will make it so that the files are put into something.tar
in the directory right above.
A more long-winded way is this:
tar cvf /path/to/something.tar $( find -name "*.txt")
That uses the direct path to where you want to put the .tar
file.
If you want actual compression:
tar cvfz something.tar.gz $( find -name "*.txt")
The z
will put it into a .gz
archive.
Basically, you want to use cvf
or cfvz
as the c
will compress the contents into an actual archive. Using t
as in your tvf
command is to send the contents of the archive to standard output without extracting it which won't work as you haven't creating the .tar
archive yet.
You may also need to escape the *
depending on your environment:
tar cvf ../something.tar $( find -name "*.txt")
Another update for anyone who may need this in the future:
For anyone else who wants to use this, if you don't have findutils
installed, it will be necessary to include the path that you are searching before -name
in the find command:
tar cvf ../something.tar $( find . -name "*.txt")
tar cvf ../something.tar $( find /path/to/directory -name "*.txt")
The first searches in the current directory and the second searches using the path to the directory.
edited Sep 11 at 15:35
answered Sep 11 at 0:28
Nasir Riley
1,754139
1,754139
add a comment |Â
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%2f468137%2fmake-tar-archive-in-parent-directory%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
1
By the way, the question and answer assume GNU findutils is used, because it omits the (POSIX-required) parameter before
-name
.â Thomas Dickey
Sep 11 at 1:03
@ThomasDickey I'm going to assume that the command worked as the answer was accepted (it also worked in the environment where I tested) but I went ahead and added the
find
command with the parameters before-name
at the end of my answer as you've made a good point.â Nasir Riley
Sep 11 at 12:05