mv

Linux 2021. 1. 19. 16:58

mv : Move 파일을 다른 디렉토리로 이동

mv 파일이름 디렉토리이름/

 

sunhangui-MacBookAir:dir2 sunhangcho$ ls -l #디렉토리2 자세히 보기

total 0

-rw-r--r--  1 sunhangcho  staff    0  1 19 14:30 aaa

drwxr-xr-x  5 sunhangcho  staff  160  1 19 16:48 dir3

-rw-r--r--  1 sunhangcho  staff    0  1 19 16:50 mv.txt #디렉토리2에 있음

sunhangui-MacBookAir:dir2 sunhangcho$ mv mv.txt dir3/  #디렉토리3으로 이동

sunhangui-MacBookAir:dir2 sunhangcho$ ls -l dir3/ #디렉토리3 자세히 보기

total 0

-rw-r--r--  1 sunhangcho  staff  0  1 19 12:43 1.txt

-rw-r--r--  1 sunhangcho  staff  0  1 19 12:43 2.txt

-rw-r--r--  1 sunhangcho  staff  0  1 19 16:50 mv.txt #디렉토리3에 있음

-rw-r--r--  1 sunhangcho  staff  0  1 19 16:48 rename

 

mv 파일이름 변경파일이름 #mv로도 파일이름을 변경할 수 있음

 

sunhangui-MacBookAir:dir2 sunhangcho$ ls -l

total 0

-rw-r--r--  1 sunhangcho  staff    0  1 19 14:30 aaa

drwxr-xr-x  5 sunhangcho  staff  160  1 19 16:51 dir3

-rw-r--r--  1 sunhangcho  staff    0  1 19 16:52 rename #디렉토리 2에 리네임 파일

sunhangui-MacBookAir:dir2 sunhangcho$ mv rename rename2 #파일 이름 변경

sunhangui-MacBookAir:dir2 sunhangcho$ ls -l

total 0

-rw-r--r--  1 sunhangcho  staff    0  1 19 14:30 aaa

drwxr-xr-x  5 sunhangcho  staff  160  1 19 16:51 dir3

-rw-r--r--  1 sunhangcho  staff    0  1 19 16:52 rename2 #디렉토리2에 rename이 rename2로 변경됨

sunhangui-MacBookAir:dir2 sunhangcho$ 

 

mv로 디렉토리 이름도 바꿀수 있음

mv /디렉토리위치/디렉토리위치/디렉토리(바꾸고 싶은 거)      /디렉토리위치/디렉토리위치/디렉토리(바꾸고싶은 이름)

sunhangui-MacBookAir:sunhangcho sunhangcho$ ls -l

total 0

drwx------@  5 sunhangcho  staff   160  1 19 11:19 Desktop

drwx------@  4 sunhangcho  staff   128  1 18 15:58 Documents

drwx------+ 30 sunhangcho  staff   960  1 19 10:47 Downloads

drwx------@ 63 sunhangcho  staff  2016  1 14 22:23 Library

drwx------+  3 sunhangcho  staff    96  1  8 14:27 Movies

drwx------+  3 sunhangcho  staff    96  1  8 14:27 Music

drwxr-xr-x   9 sunhangcho  staff   288  1  9 10:02 PacketTracer7.3.1.0362

drwx------+  3 sunhangcho  staff    96  1  8 14:27 Pictures

drwxr-xr-x+  4 sunhangcho  staff   128  1  8 14:27 Public

drwxr-xr-x   2 sunhangcho  staff    64  1 19 14:20 aa

drwxr-xr-x   7 sunhangcho  staff   224  1 19 12:34 aaa #이거를 linux 디렉토리 바꿈

drwxr-xr-x   6 sunhangcho  staff   192  1 14 12:32 cisco project

sunhangui-MacBookAir:sunhangcho sunhangcho$ mv /users/sunhangcho/aaa /users/sunhangcho/linux

 

total 0

drwx------@  5 sunhangcho  staff   160  1 19 11:19 Desktop

drwx------@  4 sunhangcho  staff   128  1 18 15:58 Documents

drwx------+ 30 sunhangcho  staff   960  1 19 10:47 Downloads

drwx------@ 63 sunhangcho  staff  2016  1 14 22:23 Library

drwx------+  3 sunhangcho  staff    96  1  8 14:27 Movies

drwx------+  3 sunhangcho  staff    96  1  8 14:27 Music

drwxr-xr-x   9 sunhangcho  staff   288  1  9 10:02 PacketTracer7.3.1.0362

drwx------+  3 sunhangcho  staff    96  1  8 14:27 Pictures

drwxr-xr-x+  4 sunhangcho  staff   128  1  8 14:27 Public

drwxr-xr-x   2 sunhangcho  staff    64  1 19 14:20 aa

drwxr-xr-x   6 sunhangcho  staff   192  1 14 12:32 cisco project

drwxr-xr-x   7 sunhangcho  staff   224  1 19 12:34 linux  #aaa에서 linux로 바뀜

sunhangui-MacBookAir:sunhangcho sunhangcho$ 

'Linux' 카테고리의 다른 글

nano 파일 에디터  (0) 2021.01.19
sudo  (0) 2021.01.19
기본명령어  (0) 2021.01.19
cd, rm, rm-r  (0) 2021.01.18
기본 명령어 pwd, mkdir, ls, ls -l  (0) 2021.01.18
블로그 이미지

JustDoIt_Sun

,