centos7의 zip 제외 폴더

centos7의 zip 제외 폴더

아래 명령을 성공적으로 테스트했지만 성공하지 못했습니다... CentOS 7에서 특정 하위 디렉터리(및 그 안에 있는 모든 파일)를 어떻게 제외합니까?

zip -r file.zip /var/www/html/ -x "/var/www/html/exclude1/" -x "/var/www/html/exclude2/" -x "/var/www/html/exclude3/"

zip -r file.zip /var/www/html/ -x /var/www/html/exclude1/**\* /var/www/html/exclude2/**\* /var/www/html/exclude3/**\*

zip -r file.zip /var/www/html/ -x /var/www/html/exclude1/ /var/www/html/exclude2/ /var/www/html/exclude2/

답변1

올바른 구문은 다음과 같습니다.

zip -r file.zip /var/www/html/ -x "/var/www/html/exclude1*" "/var/www/html/exclude2*" "/var/www/html/exclude3*"

예:

아래에 일부 디렉터리와 파일을 만들었습니다 /tmp/tozip. 각 디렉터리에는 test.txt파일이 포함되어 있습니다.

$ find /tmp/tozip/ -type d
/tmp/tozip/
/tmp/tozip/exclude
/tmp/tozip/fol1
/tmp/tozip/fol1/exclude
/tmp/tozip/fol2
/tmp/tozip/fol2/exclude
/tmp/tozip/fol3
/tmp/tozip/fol3/fol2
/tmp/tozip/fol3/fol2/fol1
/tmp/tozip/fol3/fol2/fol1/exclude

$ find /tmp/tozip/ -wholename '*exclude/*'
/tmp/tozip/exclude/test.txt
/tmp/tozip/fol1/exclude/test.txt
/tmp/tozip/fol2/exclude/test.txt
/tmp/tozip/fol3/fol2/fol1/exclude/test.txt

$ zip myzip.zip -r /tmp/tozip -x "/tmp/tozip/fol1/exclude*" "/tmp/tozip/fol2/exclude*" "/tmp/tozip/fol3/fol2/fol1/exclude*" "/tmp/tozip/exclude*"
  adding: tmp/tozip/ (stored 0%)
  adding: tmp/tozip/fol1/ (stored 0%)
  adding: tmp/tozip/fol1/test.txt (stored 0%)
  adding: tmp/tozip/fol2/ (stored 0%)
  adding: tmp/tozip/fol2/test.txt (stored 0%)
  adding: tmp/tozip/fol3/ (stored 0%)
  adding: tmp/tozip/fol3/fol2/ (stored 0%)
  adding: tmp/tozip/fol3/fol2/fol1/ (stored 0%)
  adding: tmp/tozip/fol3/fol2/fol1/test.txt (stored 0%)
  adding: tmp/tozip/fol3/fol2/test.txt (stored 0%)
  adding: tmp/tozip/fol3/test.txt (stored 0%)
  adding: tmp/tozip/test.txt (stored 0%)

내 우편번호:

$ zip -help
Copyright (c) 1990-2008 Info-ZIP - Type 'zip "-L"' for software license.
Zip 3.0 (July 5th 2008). Usage:

테스트의 기능:

mkdir -p /tmp/tozip/exclude /tmp/tozip/fol1/exclude /tmp/tozip/fol2/exclude  /tmp/tozip/fol3/fol2/fol1/exclude

find /tmp/tozip/ -type d -exec touch "{}/test.txt" \;

zip myzip.zip -r /tmp/tozip -x "/tmp/tozip/fol1/exclude*" "/tmp/tozip/fol2/exclude*" "/tmp/tozip/fol3/fol2/fol1/exclude*" "/tmp/tozip/exclude*"

관련 정보