·터미널 명령어

zip

압축·전송

쓰는 꼴

zip -r <archive.zip> <path>

압축까지 스스로 하는 묶음 꼴이라, Windows에서 아무것도 깔지 않고 그냥 열리는 것이 이것입니다 — 폴더를 담으려면 `-r`이 있어야 하고(없으면 폴더 항목만 들어가고 속은 비어 있습니다), `-e`로 거는 잠금은 옛 ZipCrypto라 약합니다.

자주 쓰는 옵션

옵션
-rRecurse into directories. Without it you archive the directory entry and nothing inside.
-x '*/node_modules/*'Exclude a pattern. Quote it so the shell leaves it alone.
-ePrompt for a password. This is legacy ZipCrypto, which is weak.
-1 / -9Fastest / smallest.
-jStore bare file names and drop the directory structure.
-uAdd only files that are new or changed.
-s 100mSplit the archive into 100 MB volumes.

예시

zip -r site.zip site -x '*/node_modules/*'

The archive a Windows colleague can open, without the dependency tree.

zip -j photos.zip ~/Pictures/*.jpg

One flat archive of files from several places.

압축과 묶음은 다른 일입니다. tar가 묶고 gzip이 줄이며, .tar.gz는 그 둘을 겹친 것입니다.

읽는 방법

  • 대괄호 [ ]는 넣어도 되고 안 넣어도 되는 자리입니다.
  • 점 셋 …은 여러 개를 이어 쓸 수 있다는 뜻입니다.
  • 옵션은 대소문자를 가립니다 — -r과 -R이 다른 명령도 있습니다.

자주 묻는 것

Q. zip은 무엇을 하나요?

압축까지 스스로 하는 묶음 꼴이라, Windows에서 아무것도 깔지 않고 그냥 열리는 것이 이것입니다 — 폴더를 담으려면 `-r`이 있어야 하고(없으면 폴더 항목만 들어가고 속은 비어 있습니다), `-e`로 거는 잠금은 옛 ZipCrypto라 약합니다.

Q. 어떻게 치나요?

zip -r <archive.zip> <path> — 대괄호는 생략할 수 있는 자리입니다.

Q. 옵션은 몇 개나 자주 쓰나요?

여기 정리한 것은 7개입니다. 전체 목록은 man zip에 있습니다. 이 명령은 압축·전송 갈래입니다.

같이 보는 명령

man 페이지: man zip