LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Question about files with ~ at the end (https://www.linuxquestions.org/questions/linux-newbie-8/question-about-files-with-%7E-at-the-end-529791/)

Murkhadh 02-16-2007 09:43 PM

Question about files with ~ at the end
 
This probably sounds like a newb question but why is it that sometimes when I edit a file (vim) that after i hit :q or :wq to close it. there is a file of the same name in the directory now with a ~ at the end of it

for example, I closed "file1.conf" by typing :wq in vim

then I ls-l in the directory and I have

file1.conf
file1.conf~

billymayday 02-16-2007 09:48 PM

I guess it's a backup - do a test and have a look at the two files

bigrigdriver 02-16-2007 09:53 PM

The most common reason (that I have seen) for the tilde (~) at the end of a file is that there was an improper shutdown which left a temp file behind.

Some applications will leave a copy of the original file with a file extension, such as; .bak, .orig, etc.

Since you don't name the distro you are using, and the :wq is a proper shutdown for vim, I suspect that is the backup file (a copy of the original) before you edited the file. If anything goes wrong after your edit, you can easily restore to a working condition by copying the <filename>~ to <filename>.

You should do some research into vim and how to turn off the backup feature if you don't want it.

billymayday 02-16-2007 09:57 PM

From

http://vimdoc.sourceforge.net/cgi-bi...q2html3.pl#7.1

Quote:

7.1. When I edit and save files, Vim creates a file with the same name as
the original file and a "~" character at the end. How do I stop Vim
from creating this file? (or) How do I disable the Vim backup file
feature?

You have set the 'backup' option, so Vim creates a backup file when saving
the original file. You can stop Vim from creating the backup file, by
clearing the option:

:set nobackup

Note that, by default this option is turned off. You have explicitly
enabled the 'backup' option in one of the initialization files. You may
also have to turn off the 'writebackup' option:

:set nowritebackup

For more information, read

:help 07.4
:help backup-table
:help 'backup'
:help 'writebackup'
:help 'backupskip'
:help 'backupdir'
:help 'backupext'
:help 'backupcopy'
:help backup

Murkhadh 02-16-2007 11:09 PM

Thank u for the replies. The distro is Slackware. I am going to check those vim settings.

billymayday 02-16-2007 11:12 PM

I guess from within vim, just type set nobackup


All times are GMT -5. The time now is 01:56 AM.