zip : 인수 목록이 너무 깁니다 (전체적으로 80.000 개 파일) 명령입니다. zip -s 200M photos_test/* 그러나

80.000 파일을 여러 개의 zip 파일로 압축해야합니다. 이것이 내가 사용하는 명령입니다.

zip -s 200M photos_test/*

그러나 다음과 같은 오류가 발생합니다.

-bash: /usr/bin/zip: Argument list too long

폴더 파일을 수동으로 분할하는 것 외에이 문제를 해결하려면 어떻게해야합니까?

감사



답변

전체 디렉토리를 원하면 -r스위치 를 사용하면됩니다 .

zip -r -s 200M myzip photos_test

여기에는 모든 하위 디렉토리가 포함됩니다 photos_test.


답변

문제는 “*”의 확장 인 것 같습니다. 폴더 이름 또는 “.”을 사용하십시오.

zip 내에 루트 폴더를 포함 시키려면 다음을 수행하십시오.

zip -r my.zip folder_with_80k_files

zip 안에 루트 폴더를 포함시키지 않으려면 :

cd folder_with_80k_files
zip -r my.zip .

답변

find photos_test/ -mindepth 1 -maxdepth 1 | zip -@ -s 200M

답변

ls photos_test | zip -s 200M -@ photos

  • -@zip이 stdin 에서 파일 목록을 읽게합니다.
  • |명령 의 입력 으로 출력 을 파이프합니다lszip

man zip:

USE
⋮
   -@ file lists.  If a file list is specified as -@ [Not on MacOS], zip takes
   the  list  of  input  files from standard input instead of from the command
   line.  For example,

          zip -@ foo

   will store the files listed one per line on stdin in foo.zip.

   Under Unix, this option can be used to powerful effect in conjunction  with
   the  find (1)  command.   For example, to archive all the C source files in
   the current directory and its subdirectories:

          find . -name "*.[ch]" -print | zip source -@

   (note that the pattern must be quoted to keep the shell from expanding it).
⋮

답변