What is the correct way to use the --remove-files
option when using tar
?
Is it...
tar -cfvj --remove-files archive.tar.bz2 archive/
Or...
tar -cfvj archive.tar.bz2 archive/ --remove-files
What is the correct way to use the --remove-files
option when using tar
?
Is it...
tar -cfvj --remove-files archive.tar.bz2 archive/
Or...
tar -cfvj archive.tar.bz2 archive/ --remove-files
Since the
-f
argument is tellingtar
you are going to speficy the file name of the archive you are acting on, I would keep the archive name right after that argument. The list of files and directories to include in the archive should come last. You can specify--remove-files
before your other arguments like this:For me, the archive file name MUST be after the
-f
option to avoid bad interpretation and make it easier to understand.In my scripts, I prefer to use this syntax :
I've only switched the
j
andf
options and moved theremove
before the dir to archive.The
-c
(--create
) is a function to create the tar file, and must be at the beginning.