본문 바로가기

Work Box (Ubuntu Server)

[Ubuntu][vi/vim] Found a swap file by the name 해결 방법

vim 으로 수정중 키를 잘못 눌러 비정상적으로 vim editing 이 종료됐다..

그 이후 파일에 접근시 Found a swap file by the name 오류가 발생한다. 물론 실행에는 문제가 없으나 거슬럭거린다.

해결해보쟈!

 

E325: ATTENTION
        Found a swap file by the name "hahaha.sh"
                  owned by: hallym   dated: Sat Apr 17 01:17:42 2021
                 file name: ~hallym/week07/week07-02.c
                  modified: YES
                 user name: hallym   host name: S26-VM-N8-186
                process ID: 12101 (still running)
        While opening file "hahaha.sh"
                     dated: Fri Apr 16 09:45:23 2021

        (1) Another program may be editing the same file.  If this is the case,
            be careful not to end up with two different instances of the same
            file when making changes.  Quit, or continue with caution.
        (2) An edit session for this file crashed.
            If this is the case, use ":recover" or "vim -r hahaha.sh"
            to recover the changes (see ":help recovery").
            If you did this already, delete the swap file "hahaha.sh"
            to avoid this message.

        Swap file "hahaha.sh" already exists!
        [O]pen Read-Only, (E)dit anyway, (R)ecover, (Q)uit, (A)bort:

vim 으로 접근시 상기와 같은 오류가 발생한다. 

 

1. Q or A 를 눌러 빠져나간다.

 

2. ps 명령어로 vim 실행상태 확인

$ ps
        PID TTY          TIME CMD
        12085 pts/0    00:00:00 bash
        12101 pts/0    00:00:00 vim
        12106 pts/0    00:00:00 ps

그럼 이런 결과가 나온다. ps 로 vim 의 실행 상태를 확인 할 수 있다.

 

3. 만약 실행중이라면 kill 명령어를 통해 해당 프로세스 종료

$ kill -9 12101
[1]+  Killed                  vim hahaha.sh

 

4. 다시 vim 으로 상기 파일을 열면 1번과 같은 화면이 뜨는데 Delete 옵션이 추가된것을 확인 가능하다.

       E325: ATTENTION
        Found a swap file by the name "hahaha.sh"
                  owned by: hallym   dated: Sat Apr 17 01:17:42 2021
                 file name: ~hallym/week07/hahaha.sh
                  modified: YES
                 user name: hallym   host name: S26-VM-N8-186
                process ID: 12101
        While opening file "hahaha.sh"
                     dated: Fri Apr 16 09:45:23 2021

        (1) Another program may be editing the same file.  If this is the case,
            be careful not to end up with two different instances of the same
            file when making changes.  Quit, or continue with caution.
        (2) An edit session for this file crashed.
            If this is the case, use ":recover" or "vim -r hahaha.sh"
            to recover the changes (see ":help recovery").
            If you did this already, delete the swap file "hahaha.sh"
            to avoid this message.

        Swap file "hahaha.sh" already exists!
        [O]pen Read-Only, (E)dit anyway, (R)ecover, (D)elete it, (Q)uit, (A)bort:

Delete 옵션을 선택: D 를 입력한다.

 

5. 삭제 후 닷 vim 을 통해 들어가면 상기의 오류는 없이 정상적으로 실행 된다.