Если вы хотите весь каталог, вы можете просто использовать -r
переключатель:
zip -r -s 200M myzip photos_test
Это будет включать в себя все подкаталоги, 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|
будет конвейер выхода из ls
в вход из zip
команды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). ⋮