하루 리눅스 명령 : MV (7)

MV

MV 명령 파일 (이동 (이름 바꾸기) 파일) 파일을 이동하거나 이름을 변경하는 데 사용할 수있는 리눅스 시스템 종종 파일이나 디렉토리를 백업하는 데 일반적으로 사용되는 명령. 첫 번째 파일 시스템, MV 복사를 통해 파일을 이동 한 후 원본 파일을 삭제하고 파일에 체인 링크가 손실 될 때

체재

MV [옵션] 원본 파일이나 디렉토리 대상 파일이나 디렉토리

매개 변수 옵션

매개 변수
-비 첫 번째 백업이 덮어 쓰기 전에 들어하는 파일을 덮어 씁니다.
-에프 대상 파일이 이미 존재하지만 직접 적용 요구하지 않을 경우, 필수 감각을 강제;
-나는 대상 파일 (대상)이 이미 존재하는 경우, 덮어 쓰기 할 것인지 물어볼 것입니다!
-u 대상 파일이 이미 존재하고 소스가 상대적으로 새로운 경우, 업데이트됩니다 (갱신)
-티 --target 디렉토리 = DIRECTORY 디렉토리에 모든 소스 인수 이동이 옵션을 MV, 즉 지정된 목적지 디렉토리는 디렉토리 소스 복수의 파일을 이동하는 경우에 적용되는 경우에는 이전 대상 디렉토리의 소스 파일.

  • 파일 이름

    명령 : MV oldNameFile newNameFile

    [root@VM_0_9_centos ~]# mkdir test
    [root@VM_0_9_centos ~]# cd test
    [root@VM_0_9_centos test]# touch oldNameFile
    [root@VM_0_9_centos test]# ls
    oldNameFile
    [root@VM_0_9_centos test]# mv oldNameFile newNameFile
    [root@VM_0_9_centos test]# ls
    newNameFile
    [root@VM_0_9_centos test]# 
  • 이동 파일

    명령 : MV MYFILE.TXT ./temp/myFile.txt

    [root@VM_0_9_centos test]# touch myFile.txt
    [root@VM_0_9_centos test]# tree
    .
    |-- myFile.txt
    `-- temp
    
    1 directory, 1 file
    
    [root@VM_0_9_centos test]# mv myFile.txt ./temp/myFile.txt
    [root@VM_0_9_centos test]# tree
    .
    `-- temp
        `-- myFile.txt
    
    1 directory, 1 file
  • 파일 myFile1도하여 myfile2도 직접 스왑을 포함, 존재하여 myfile2 개명

    명령 : MV -f myfile1하여 myfile2

    [root@VM_0_9_centos test]# ll
    total 0
    -rw-r--r-- 1 root root 0 Oct 27 10:05 myFile1
    -rw-r--r-- 1 root root 0 Oct 27 10:06 myFile2
    [root@VM_0_9_centos test]# mv myFile1 myFile2
    mv: overwrite ?.yFile2?. n
    [root@VM_0_9_centos test]# mv -f  myFile1 myFile2
    [root@VM_0_9_centos test]# ll
    total 0
    -rw-r--r-- 1 root root 0 Oct 27 10:05 myFile2
    [root@VM_0_9_centos test]# 
  • 적용하기 전에 간단한 파일 백업을 수행

    명령 : MV -b myfile1하여 myfile2

    [root@VM_0_9_centos test]# ll
    total 0
    -rw-r--r-- 1 root root 0 Oct 27 10:14 myFile1
    -rw-r--r-- 1 root root 0 Oct 27 10:05 myFile2
    [root@VM_0_9_centos test]# mv -b myFile1 myFile2
    mv: overwrite ?.yFile2?. y
    [root@VM_0_9_centos test]# ll
    total 0
    -rw-r--r-- 1 root root 0 Oct 27 10:14 myFile2
    -rw-r--r-- 1 root root 0 Oct 27 10:05 myFile2~

    -b이 인수를 허용하지 않습니다, MV 백업 전략으로 VERSION_CONTROL 환경 변수를 읽을 수있을 것이다.

    대상 파일이 지정된 조치가, 넷 개 백업 전략이있는 경우이 옵션을 --backup :

    1.CONTROL = 없음 또는 오프 : 백업.

    번호 백업 : 2.CONTROL = 번호 또는 t

    3.CONTROL = 기존 또는 전무는 : 수 디지털 백업에서 존재하면, 백업 번호 m + 1 계속 ... N :

    MV 번째 문서 log2.txt의 존재하에 수행 된 동작 전의. 등등 ~ 1 ~ 실행 다시 생성 log2.txt ~ 2 ~ 열등 경주하고. 이전에 번호를 문서화하지 않으면, 아래에 언급 된 간단한 백업을 사용합니다.

    4.CONTROL = 단순 또는 결코 : 사용 단순 백업 : 적용되기 전에 간단한 백업 만, 다시 적용, 간단한 백업이 덮어 쓰기됩니다 간단한 백업이있다.

    [root@VM_0_9_centos test]# mv -b --backup=numbered myFile2
    mv: missing destination file operand after ?.yFile2?
    Try 'mv --help' for more information.
    [root@VM_0_9_centos test]# mv -b --backup=numbered myFile1 myFile2
    mv: overwrite ?.yFile2?. y
    [root@VM_0_9_centos test]# ll
    total 0
    -rw-r--r-- 1 root root 0 Oct 27 10:27 myFile2
    -rw-r--r-- 1 root root 0 Oct 27 10:16 myFile2.~1~
    [root@VM_0_9_centos test]# 
  • 디렉토리에 여러 파일을 이동

    명령 : .. 뮤직 비디오 -t 백업 / myfile2가 1 ~ ~ ~하여 myfile2

    [root@VM_0_9_centos test]# mkdir backup
    [root@VM_0_9_centos test]# ll
    total 4
    drwxr-xr-x 2 root root 4096 Oct 27 10:33 backup
    -rw-r--r-- 1 root root    0 Oct 27 10:27 myFile2
    -rw-r--r-- 1 root root    0 Oct 27 10:16 myFile2~
    -rw-r--r-- 1 root root    0 Oct 27 10:16 myFile2.~1~
    [root@VM_0_9_centos test]# mv -t backup/ myFile2~ myFile2.~1~ 
    [root@VM_0_9_centos test]# tree
    .
    |-- backup
    |   |-- myFile2~
    |   `-- myFile2.~1~
    `-- myFile2
    
    1 directory, 3 files

참고

추천

출처www.cnblogs.com/DiDi516/p/11746790.html