1

If I am trying to archive files in loop using tar command with --remove-files option. If some exception occurs in mid of execution, will the --remove-files option delete the current operating file or retain the original file ?

while read file; 
do
    tar -uf test.tar.gz --remove-files "$file"              
done
0

As far as my experiments go (and somehow as I expected):

  • the source file is removed only if the command completes normally
  • however, "-u" doesn't remove the previous version of the file, it merely adds it to the end, so repeated updates with the same file will make the TAR file grow indefinitely.
  • I want to know status of source file which will be added in tar file.It will be deleted/retained ? if exception occurs in archiving the file. – Tejas Jun 16 '16 at 13:23
  • As I said the source file is retained if anything bad happens. – xenoid Jun 16 '16 at 14:05

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.