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.


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):

tar: file1.zip: skipping existing file
tar: file2.zip: skipping existing file

I need only the file3.zip in the output. Is it possible?

  • 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

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


tar --skip-old-files --extract --file=2019-02-10.tar.gz
find . -cnewer $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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.