Hi

Tar does not remove files after creating the archive (with the -r flag) as stated in the man pages:

With the -c flag it works correctly.

--remove-files
              remove files after adding them to the archive




Here is my script:
[cobus@dev2 tmp]$ cat ./tts.sh
echo "hello there" > toets.txt
sleep 1
ls -l toets.txt
tar -rf archivetest.tar toets.txt --remove-files
rc=$?
echo "rc = $rc"
sleep 1
ls -l toets.txt

And the result:

[cobus@dev2 tmp]$ ./tts.sh
-rw-rw-r--. 1 cobus cobus 11 Jul 11 09:12 toets.txt
rc = 0
-rw-rw-r--. 1 cobus cobus 11 Jul 11 09:12 toets.txt
[cobus@dev2 tmp]$

==========================================================

[cobus@dev2 tmp]$ cat ./tts.sh
echo "hello daar" > toets.txt
sleep 1
ls -l toets.txt
tar -cvf archivetest.tar toets.txt --remove-files
rc=$?
echo "rc = $rc"
sleep 1
ls -l toets.txt

[cobus@dev2 tmp]$ ./tts.sh
-rw-rw-r--. 1 cobus cobus 11 Jul 11 09:22 toets.txt
toets.txt
rc = 0
ls: cannot access toets.txt: No such file or directory
[cobus@dev2 tmp]$


[cobus@dev2 tmp]$ uname -a
Linux dev2 2.6.32-220.17.1.el6.x86_64 #1 SMP Wed May 16 00:01:37 BST 2012 x86_64 x86_64 x86_64 GNU/Linux
[cobus@dev2 tmp]$




Kind regards

--

Cobus Aikman


[email protected]


Reply via email to