The tar command just overwrote my file an hour ago while I was trying to make a tar to backup it. I rantar zcvf foo.tex foo.biband after that my tex source file lost. What's worse, this is the second time I lost my file in this way.I use gvim, but 'u' command can recover my file. After browsing some help entries about 'backup', 'undofile', I just can not find a way to avoid tar command from overwriting my file again.Then I try to find a parameter like '-i' from cp or mv, but among the many parameters of tar I can't find one.I wonder how can I avoid this kind of things happening again, for I am a little unconfident about remembering to add the new foo.tar thing that I always forget next time.
How to avoid overwriting existing files while using tar command?
bash;tar;data recovery
Add this to your .bash_login file.  alias tar=tar --backup=simple  This will append a ~ to the file it is about to overwrite.So when you create the archive it will always runtar --backup=simple zcvf foo.tex foo.biband after execution a foo.tex~ will exist (this is the actual tex file and the archive will be in at foo.tex)