Linux

[Linux] touch, mv, cp, rm 명령어

twoDeveloper 2021. 8. 11. 23:02

■ touch 명령어

$ touch [Option] [File]

- 빈 파일을 생성한다.

 

ex)

$ touch fileName{1..9}.txt

- {1..9}를 통해 빈 파일 9개 생성

 

 

■ mv 명령어

$ mv [Option] [이동시킬 파일] [이동시킬 경로]

- 파일을 이동시킨다.

 

ex)

$ mv fileName[123].txt Public/

- fileName1.txt, fileName2.txt, fileName3.txt 파일을 한번에 Public 디렉토리에 이동

 

$ mv fileName{1..9}.txt Public/

- fileName1 ~ 9.txt 파일이 한번에 Public 디렉토리에 이동

 

 

■ cp 명령어

$ cp [Option] [복사할 파일] [복사할 파일 경로]

- 파일을 복사한다.

- 복사 대상이 디렉토리라면 -r 옵션 필수! 

 

ex)

$ cp fileName{1..9} Public/
$ cp fileName*.txt Public/

- fileName1 ~ 9.txt 를 Public 디렉토리 파일에 복사

 

 

■ rm 명령어

$ rm [Option] [File]

- 파일을 삭제한다.

- 삭제 대상이 디렉토리라면 -r 옵션 필수!

- rm -rf 삭제 여부를 묻지 않고 바로 삭제, 따라서 조심해서 사용할 것