현재 디렉토리의 파일 및 폴더를 포함하여 모든 것을 압축하여 우분투의 단일 ZIP 파일로 패키지하고 싶습니다.
이 작업에 가장 편리한 명령은 무엇입니까 (및 도구 이름이있는 경우 설치해야 함)?
편집 : 하나의 폴더 또는 여러 파일을 제외해야하는 경우 어떻게합니까?
답변
설치 zip
및 사용
zip -r foo.zip .
플래그 -0
(없음)에서 -9
(최고)를 사용하여 압축률을 변경할 수 있습니다
-x
플래그 를 통해 파일 제외를 수행 할 수 있습니다 . 맨 페이지에서 :
-x files
--exclude files
Explicitly exclude the specified files, as in:
zip -r foo foo -x \*.o
which will include the contents of foo in foo.zip while excluding all the files that end in .o. The backslash avoids the shell filename substitution, so that the name matching
is performed by zip at all directory levels.
Also possible:
zip -r foo foo -x@exclude.lst
which will include the contents of foo in foo.zip while excluding all the files that match the patterns in the file exclude.lst.
The long option forms of the above are
zip -r foo foo --exclude \*.o
and
zip -r foo foo --exclude @exclude.lst
Multiple patterns can be specified, as in:
zip -r foo foo -x \*.o \*.c
If there is no space between -x and the pattern, just one value is assumed (no list):
zip -r foo foo -x\*.o
See -i for more on include and exclude.