태그 보관물: compression

compression

현재 디렉토리에 모든 것을 압축 단일 ZIP 파일로 패키지하고 싶습니다. 이 작업에 가장

현재 디렉토리의 파일 및 폴더를 포함하여 모든 것을 압축하여 우분투의 단일 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.

답변

Google을 통해이 질문에 온 많은 사람들이 “zip”을 쓸 때 “보관 및 압축”을 의미한다고 생각합니다. zip 형식 의 대안 은 tar입니다 .

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

답변