사이트 내 전체검색
[ajax] tar로 특정 디렉토리 제외시키고 묶기
로빈아빠
https://cmd.kr/server/124 URL이 복사되었습니다.

본문

디렉토리 구조

/home/test/

/home/test/test1/

/home/test/test2/

/home/test/test3/

/home/test/test4/

/home/test/test5/

 

test2 와 test3 디렉토리를 제외시키기

 

cd /home/test/

tar cvf ../test.tar --exclude test2 --exclude test3 ./

 

--exclude 옵션에서 / <- 요게 들어 가면 안된다.

 

특정디렉토만 묶을때에는

 

tar cvf ../test.tar --exclude test2 test3 test4

 

이런식으로 --exclude  를 한번만 써주고 묶을 디렉토리만 지정해주면 된다

 

또다른 방법

tar cvfX test.tar exclude.lst test
 옵션 X는 exclude.lst에 기록되어있는 파일이나 디렉토리를 제외하라는 뜻

 

 

예를 들어 아래와 같은  test 폴더가 있다.

test

 - sub_dir/

 - sub_dir2/

 - sub_dir3/

 - file1

 - file2

 

여기에서 sub_dir 폴더와 file1은 제외하고 test 폴더전체를 묶고 싶다면

1. exclude.lst 파일을 생성하여 아래와 같이 작성한다.

test/sub_dir

test/file1

 

2. TAR를 실행한다.

tar cvfX tets.tar exclude.lst test

댓글목록

등록된 댓글이 없습니다.

1,139 (8/23P)

Search

Copyright © Cmd 명령어 18.222.71.231