Show only the really extracted (non-skipped) files using tar
I'm extracting daily backup archives. I want to see only the new files since the last day. The archives contain lot of already existing files, which I don't want to overwrite, so I use the --skip-old-files
option, which is fine.
But I'd like to list only those files that were actually extracted and omit those that were skipped because they already exist.
Example:
My current command is:
tar --verbose --skip-old-files --extract --file=2019-02-10.tar.gz
and the output is (where file1 and file2 were already exist and file3 was new):
file1.zip
tar: file1.zip: skipping existing file
file2.zip
tar: file2.zip: skipping existing file
file3.zip
I need only the file3.zip in the output. Is it possible?
tar output
add a comment |
I'm extracting daily backup archives. I want to see only the new files since the last day. The archives contain lot of already existing files, which I don't want to overwrite, so I use the --skip-old-files
option, which is fine.
But I'd like to list only those files that were actually extracted and omit those that were skipped because they already exist.
Example:
My current command is:
tar --verbose --skip-old-files --extract --file=2019-02-10.tar.gz
and the output is (where file1 and file2 were already exist and file3 was new):
file1.zip
tar: file1.zip: skipping existing file
file2.zip
tar: file2.zip: skipping existing file
file3.zip
I need only the file3.zip in the output. Is it possible?
tar output
I'm realizing that you have to hope that there are no actual files named "tar: file1.zip: skipping existing file", unless you carefully manage the stdout and stderr streams...
– Jeff Schaller
Feb 26 at 18:11
Yeah, I also realized that the complexity goes too high to solve this problem with a pure output text mangling solution. The best option would be if the tar command itself could support this type of output.
– csadam
Feb 26 at 18:27
add a comment |
I'm extracting daily backup archives. I want to see only the new files since the last day. The archives contain lot of already existing files, which I don't want to overwrite, so I use the --skip-old-files
option, which is fine.
But I'd like to list only those files that were actually extracted and omit those that were skipped because they already exist.
Example:
My current command is:
tar --verbose --skip-old-files --extract --file=2019-02-10.tar.gz
and the output is (where file1 and file2 were already exist and file3 was new):
file1.zip
tar: file1.zip: skipping existing file
file2.zip
tar: file2.zip: skipping existing file
file3.zip
I need only the file3.zip in the output. Is it possible?
tar output
I'm extracting daily backup archives. I want to see only the new files since the last day. The archives contain lot of already existing files, which I don't want to overwrite, so I use the --skip-old-files
option, which is fine.
But I'd like to list only those files that were actually extracted and omit those that were skipped because they already exist.
Example:
My current command is:
tar --verbose --skip-old-files --extract --file=2019-02-10.tar.gz
and the output is (where file1 and file2 were already exist and file3 was new):
file1.zip
tar: file1.zip: skipping existing file
file2.zip
tar: file2.zip: skipping existing file
file3.zip
I need only the file3.zip in the output. Is it possible?
tar output
tar output
edited Feb 26 at 16:42
Jeff Schaller
43.5k1161140
43.5k1161140
asked Feb 26 at 16:40
csadamcsadam
1184
1184
I'm realizing that you have to hope that there are no actual files named "tar: file1.zip: skipping existing file", unless you carefully manage the stdout and stderr streams...
– Jeff Schaller
Feb 26 at 18:11
Yeah, I also realized that the complexity goes too high to solve this problem with a pure output text mangling solution. The best option would be if the tar command itself could support this type of output.
– csadam
Feb 26 at 18:27
add a comment |
I'm realizing that you have to hope that there are no actual files named "tar: file1.zip: skipping existing file", unless you carefully manage the stdout and stderr streams...
– Jeff Schaller
Feb 26 at 18:11
Yeah, I also realized that the complexity goes too high to solve this problem with a pure output text mangling solution. The best option would be if the tar command itself could support this type of output.
– csadam
Feb 26 at 18:27
I'm realizing that you have to hope that there are no actual files named "tar: file1.zip: skipping existing file", unless you carefully manage the stdout and stderr streams...
– Jeff Schaller
Feb 26 at 18:11
I'm realizing that you have to hope that there are no actual files named "tar: file1.zip: skipping existing file", unless you carefully manage the stdout and stderr streams...
– Jeff Schaller
Feb 26 at 18:11
Yeah, I also realized that the complexity goes too high to solve this problem with a pure output text mangling solution. The best option would be if the tar command itself could support this type of output.
– csadam
Feb 26 at 18:27
Yeah, I also realized that the complexity goes too high to solve this problem with a pure output text mangling solution. The best option would be if the tar command itself could support this type of output.
– csadam
Feb 26 at 18:27
add a comment |
1 Answer
1
active
oldest
votes
If this is the only process writing to the directory then you could create a temporary file, extract the files not in verbose mode, then look at those with a change time newer than the temp file
e.g.
MYTMP=$(mktemp)
tar --skip-old-files --extract --file=2019-02-10.tar.gz
find . -cnewer $MYTMP
rm $MYTMP
I will use the MYTMP to create a fixed name file (instead of temporary file) as a flag to avoid starting more than one instance. If the file exists then my script will do nothing.
– csadam
Feb 26 at 18:22
I secretly hoped there is an solution for this in the tar command itself, but it's good workaround for me.
– csadam
Feb 26 at 18:24
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "106"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
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
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f503160%2fshow-only-the-really-extracted-non-skipped-files-using-tar%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
If this is the only process writing to the directory then you could create a temporary file, extract the files not in verbose mode, then look at those with a change time newer than the temp file
e.g.
MYTMP=$(mktemp)
tar --skip-old-files --extract --file=2019-02-10.tar.gz
find . -cnewer $MYTMP
rm $MYTMP
I will use the MYTMP to create a fixed name file (instead of temporary file) as a flag to avoid starting more than one instance. If the file exists then my script will do nothing.
– csadam
Feb 26 at 18:22
I secretly hoped there is an solution for this in the tar command itself, but it's good workaround for me.
– csadam
Feb 26 at 18:24
add a comment |
If this is the only process writing to the directory then you could create a temporary file, extract the files not in verbose mode, then look at those with a change time newer than the temp file
e.g.
MYTMP=$(mktemp)
tar --skip-old-files --extract --file=2019-02-10.tar.gz
find . -cnewer $MYTMP
rm $MYTMP
I will use the MYTMP to create a fixed name file (instead of temporary file) as a flag to avoid starting more than one instance. If the file exists then my script will do nothing.
– csadam
Feb 26 at 18:22
I secretly hoped there is an solution for this in the tar command itself, but it's good workaround for me.
– csadam
Feb 26 at 18:24
add a comment |
If this is the only process writing to the directory then you could create a temporary file, extract the files not in verbose mode, then look at those with a change time newer than the temp file
e.g.
MYTMP=$(mktemp)
tar --skip-old-files --extract --file=2019-02-10.tar.gz
find . -cnewer $MYTMP
rm $MYTMP
If this is the only process writing to the directory then you could create a temporary file, extract the files not in verbose mode, then look at those with a change time newer than the temp file
e.g.
MYTMP=$(mktemp)
tar --skip-old-files --extract --file=2019-02-10.tar.gz
find . -cnewer $MYTMP
rm $MYTMP
answered Feb 26 at 17:53
Stephen HarrisStephen Harris
26.5k34980
26.5k34980
I will use the MYTMP to create a fixed name file (instead of temporary file) as a flag to avoid starting more than one instance. If the file exists then my script will do nothing.
– csadam
Feb 26 at 18:22
I secretly hoped there is an solution for this in the tar command itself, but it's good workaround for me.
– csadam
Feb 26 at 18:24
add a comment |
I will use the MYTMP to create a fixed name file (instead of temporary file) as a flag to avoid starting more than one instance. If the file exists then my script will do nothing.
– csadam
Feb 26 at 18:22
I secretly hoped there is an solution for this in the tar command itself, but it's good workaround for me.
– csadam
Feb 26 at 18:24
I will use the MYTMP to create a fixed name file (instead of temporary file) as a flag to avoid starting more than one instance. If the file exists then my script will do nothing.
– csadam
Feb 26 at 18:22
I will use the MYTMP to create a fixed name file (instead of temporary file) as a flag to avoid starting more than one instance. If the file exists then my script will do nothing.
– csadam
Feb 26 at 18:22
I secretly hoped there is an solution for this in the tar command itself, but it's good workaround for me.
– csadam
Feb 26 at 18:24
I secretly hoped there is an solution for this in the tar command itself, but it's good workaround for me.
– csadam
Feb 26 at 18:24
add a comment |
Thanks for contributing an answer to Unix & Linux Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
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
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f503160%2fshow-only-the-really-extracted-non-skipped-files-using-tar%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
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
Required, but never shown
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
Required, but never shown
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
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
I'm realizing that you have to hope that there are no actual files named "tar: file1.zip: skipping existing file", unless you carefully manage the stdout and stderr streams...
– Jeff Schaller
Feb 26 at 18:11
Yeah, I also realized that the complexity goes too high to solve this problem with a pure output text mangling solution. The best option would be if the tar command itself could support this type of output.
– csadam
Feb 26 at 18:27