현재 디렉터리의 모든 항목을 압축합니다.

현재 디렉터리의 모든 항목을 압축합니다.

현재 디렉터리의 파일과 폴더를 포함한 모든 것을 Ubuntu의 단일 ZIP 파일로 압축하고 패키지하고 싶습니다.

가장 편리한 명령은 무엇입니까(그리고 설치해야 하는 도구의 이름(있는 경우))은 무엇입니까?

편집: 폴더나 여러 파일을 제외해야 하는 경우 어떻게 해야 합니까?

답변1

설치 zip및 사용

zip -r foo.zip .

-0(None)에서 (Best)로의 플래그를 사용하여 -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 [email protected]

          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.

답변2

구글을 통해 이 질문에 답한 많은 사람들이 "zip"이라고 썼을 때 "보관 및 압축"을 의미했다고 생각합니다. 에 대한 대안zip 형식아스팔트:

tar -czf copy.tar.gz whatever/

압축된 아카이브 파일은 copy.tar.gz이고 내용은 폴더의 모든 것입니다.

 -c, --create
       create a new archive
 -z, --gzip, --gunzip --ungzip
 -f, --file ARCHIVE
       use archive file or device ARCHIVE

관련 정보