unix
tar를 이용하여 특정 파일만 엮기
mulderu
2010. 7. 16. 17:23
특정파일만 tar 묶기
유닉스에서 find 를 이용하면 다양한 파일의 리스트를 구할 수 있다.
그중에서도 우리의 관심사는 특정 확장자를 가진 파일 리스트를 구하는거고, 그걸 tar 로 묶는다면
원하는 파일만 백업하는 기능을 구현 할 수 있다.
# only java tar cvf wap.tar *.java find . -name "*.java" | xargs tar rvf jar.tar # only jsp tar cvf web.tar *.jsp find . -name "*.jsp" | xargs tar rvf jsp.tar # jsp and class find . -type f \( -iname "*.jsp" -o -iname "*.class" \) # find web/mall -type f \( -iname "*.jsp" -o -iname "*.class" \) | xargs tar cvzf backup/jsp.class.tgz