Deleting files after adding to tar archive

后端 未结 4 622
夕颜
夕颜 2021-02-02 05:40

Can GNU tar add many files to an archive, deleting each one as it is added?

This is useful when there is not enough disk space to hold both the entire tar archive and th

4条回答
  •  情深已故
    2021-02-02 06:16

    For non GNU tar, you can use "-u" to proccess file per file in a loop

    tar -cf archive.tar afile
    for myfile in dir/*.ext
    do
        tar -uf archive.tar $myfile && rm $myfile || echo "error tar -uf archive.tar $myfile"
    done
    

提交回复
热议问题