반응형

※ 스왑 파일 생성 조건
 (1) vi로 파일을 open할 경우 동일한 파일명의 스왑 파일이 숨김 파일 형태로 생성됩니다.
   - 단, 읽기전용 모드(-R)로 파일을 open할 경우에는 스왑 파일이 생성되지 않습니다.
 (2) vi로 open한 파일을 정상적으로 닫을 경우 스왑 파일이 자동으로 삭제됩니다.

하지만, vi로 파일을 열어 작업하는 도중 네트워크 상태가 불안정하거나 끊겼을 경우, 다시 동일 파일을 vi로 open 하려하면 아래와 같은 메시지가 출력됩니다. 
E325: ATTENTION
Found a swap file by the name ".test.c.swp"
          owned by: oyh dated: Tue Oct 25 23:06:24 2011
         file name: ~oyh/test/test.c
          modified: no
         user name: oyh host name: linux
        process ID: 1255 (still running)
While opening file "test.c"
             dated: Mon Oct 24 10:35:05 2011
(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 test.c"
    to recover the changes (see ":help recovery").
    If you did this already, delete the swap file ".test.c.swp"
    to avoid this message.
Swap file ".test.c.swp" already exists!
[O]pen Read-Only, (E)dit anyway, (R)ecover, (Q)uit, (A)bort:

해당 파일이 이미 open 되어있다는 내용입니다.
일단, 해당 메시지가 출력되면 다른 누군가가 파일을 열어 사용하고 있지는 않은지 반드시 !!! 확인을 해야합니다.
(누군가 정말로 파일을 사용중이라면 아래의 작업은 피하시기 바랍니다......)
누군가 파일을 사용하고 있지 않을 경우, 이전에 작업하던 코드로 복구하려면, 위의 메시지에서 (Q)를 눌러 나간 후 아래의 커맨드를 입력하여 다시 파일을 open합니다.
vi -r [파일명 or 스왑파일명]           (ex) vi -r test.c

수정 작업이 완료되면 저장하고 나간 후 스왑 파일을 삭제해주면 됩니다.


반응형

+ Recent posts