Deleting files after adding to tar archive
With GNU tar, use the option --remove-files
.
I had a task - archive files and then remove into OS installed "tar" without GNU-options.
Method:
Use "xargs"
Suppose, we are have a directory with files.
Need move all files, over the week into tar and remove it.
I do one archive (arc.tar) and added files to it. (You can create new archive every try)
Solution:
find ./ -mtime +7 | xargs -I % sh -c 'tar -rf arc.tar % && rm -f %'