실패는 성공을 위한 밑거름

[linux] 리눅스에서 파일 복사하기 본문

devops/Linux

[linux] 리눅스에서 파일 복사하기

레드매실 2023. 4. 19. 20:46

리눅스에서 cp명령어를 사용한 파일 복사하기

 

일반적인 복사방법

cp [복사할타겟파일이름] [복사할폴더]

ex) cp 1.txt movedir

 

 

디렉토리를 복사할때 명령어

cp -r 복사할파일이름 복사할이름

ex) cp -r testfile testfile1

cp -r [복사할타겟dir] [복사할폴더]

ex) cp -r targetdir afterdir

 

디렉토리를 복사할때 이미 존재하는 파일은 안바꾸는 명령어

 

cp -n [타겟dir] [복사할dir]

ex)
cp -n  /usr/local/tomcat/upload/* /shdir/bkup/upload/;

 

파일 폴더 무시하고 덮어복사하기

yes |cp -arpf [복사할 타겟dir] [복사할 dir]

ex)
yes |cp -arpf ./mydirectory1 /home/mydirectory2