Top

[리눅스] tar 특정폴더 제외하여 압축 , rm 특수문자포함된 파일 삭제 | Web-Programing
진기원 (wlsrldnjs) | Editor | 2015/05/11 14:54:10 | 조회:8208

내가 만든 프로젝트 파일을 백업해서 관리하려고,

현재 폴더에서 특정 하위 폴더를 제외한 나머지 파일&폴더를 압축 하고 싶어 구글링을 했는데.


tar [옵션] [압축파일명] [--exclude=] [제외할파일종류] [압축대상경로]

위와 같은 방식으로 하라고 되어있었는데도 불구하고..


tar zcvf --exclude= backup/ project.tar.gz ./*


위와 같이 쌩뚱맞게 명령어를 날리고 말았다. (무슨 생각으로 저 명령어를 날린거지..)


결과는...


현재폴더를 모두 압축하여 "--exclude" 라는 파일명으로 압축이 되어버렸다..


그래서 "--exclude" 파일을 삭제하고 다시 압축을 하기로 결정!

 > rm --exclude


삭제가 되지 않는다..

"-" 특수문자 때문인 것 같아.. 알아보던중


> man rm  을 해보니


The rm command uses getopt(3) to parse its arguments, which allows it to
     accept the `--' option which will cause it to stop processing flag
     options at that point.  This will allow the removal of file names that
     begin with a dash (`-').  For example:

           rm -- -filename

     The same behavior can be obtained by using an absolute or relative path
     reference.  For example:

           rm /home/user/-filename
           rm ./-filename

     When -P is specified with -f the file will be overwritten and removed
     even if it has hard links.


이렇게 되어져 있어..


 > rm -- --exclude

로 삭제 하였다 ㅠㅠ



다시 특정폴더 제외 한 압축으로 돌아가

> tar -zcvf shoppingbox_20150501.tar.gz --exclude=backup/ ./*


이렇게 압축을 성공 하였다!!


공유하기
공유하기
1
0
0


댓글을 불러오는 중입니다.
▲ 이전글 [리눅스] crontab과 sh을 활용한 간단한 데이터 백업 관리방법 진기원 (wlsrldnjs) 2015-05-11 16:10:35
▼ 다음글 [CSS,Script] 테이블 행고정 시키기 진기원 (wlsrldnjs) 2015-04-27 12:02:46