others

별도 프로그램 없이 macOS 맥에서 분할 압축 하기, 압축 풀기

마들브라더 2022. 7. 4. 15:21

맥에서 별도의 프로그램을 다운 받지 않고 분할 압축하기

터미널 실행 후 경로로 이동하기(첫번째 방법)

  1. 터미널 실행 첫번째 방법: command + space 로 Spotlight에서 터미널 혹은 terminal 검색 후 실행하기
  2. 터미널 실행 두번째 방법
    1. 응용프로그램 - 유틸리티 폴더 접근
    2. 터미널 실행
  3. 이동하기
    • 터미널에서는 ls(list) 리눅스 명령어를 이용해서 현재 위치의 폴더와 파일 리스트를 확인할 수 있다
    • 터미널에서는 cd(change directory) 리눅스 명령어를 이동해서 폴더를 이동할 수 있다
    • ls 명령어로 폴더 이름을 확인하고 cd 폴더이름 형태로 이동할 수 있다
    • cd 폴더이름/폴더이름2/폴더이름3 형태로 한번에 이동할 수 있다
    • cd 를 입력후 tab Key를 누르면 현재 위치에서 폴더들을 쉽게 이동하며 입력할 수 있다
    • tab key로 이동 후 /키를 누르면 계속해서 폴더 이름을 이어나갈 수 있다

터미널 실행 후 경로로 이동하기(두번째 방법)

  1. 파인더 하단의 경로에서 터미널을 열고 싶은 폴더를 오른쪽 클릭한 후 폴더에서 새로운 터미널 열기를 클릭한다
    • 경로가 보이지 않는 경우 Finder 상단 보기 메뉴 - 경로 막대보기 를 클릭하거나 command + option + p 키로 경로 막대를 활성화 할 수 있다

압축하기

  • 터미널에서 기본으로 제공하는 zip 명령어를 사용해서 압축하기기본 압축
  • zip A B형식으로 압축을 할 수 있다
  • 여기서 A는 압축한 후 만들어질 압축파일의 이름이다
  • B는 압축하고자 하는 폴더 또는 파일의 이름이다
  • 현재 위치에는 TV라는 폴더가 있고 zip zippedTV TV/라는 명령어를 통해서 TV라는 폴더를 압축할 수 있다
  • 다만 파일이 아닌 폴더를 압축하기 위해서는 폴더 안의 데이터까지 모두 압축하기 위해서 zip -r A B(폴더) 형태의 명령어를 사용해야 한다
  • -r 라는 옵션은 recurse into directories, 내부 폴더까지 반복해서 압축한다는 뜻이다
  • 생성된 파일

분할 압축하기

  • -s 라는 splits 옵션을 추가해서 분할 압축을 할 수 있다
  • 전체 명령어는 폴더의 경우 zip -r -s 분할하고자하는최대용량 A B 형태로 사용가능하다
  • 여기서 분할하고자 하는 최대 용량은 5m을 입력할 때, 5MB씩 분할된다
  • 숫자 뒤에 단위를 사용하는데 m이 기본값이며 k, m, g, t를 사용할 수 있다
  • k는 kB, m은 MB(생략가능), g는 기가바이트(GB), t는 테라바이트(TB) 옵션이다
  • 참고
zip -h2

........

Basic command line:  
zip options archive\_name file file ...

Basic options:  
Some examples:  
Add file.txt to z.zip (create z if needed): zip z file.txt  
Zip all files in current dir: zip z \*  
Zip files in current dir and subdirs also: zip -r z .

........

Splits (archives created as a set of split files):  
\-s ssize create split archive with splits of size ssize, where ssize nm  
n number and m multiplier (kmgt, default m), 100k -> 100 kB

분할된 압축파일 풀기

  • 분할된 압축파일을 풀기 위해서는 일단 하나의 zip파일로 다시 합치는 과정이 필요하다
  1. 터미널 실행
  2. 압축풀고자 하는 파일(*.zip)이 위치한 경로로 이동
  3. 명령어 실행 zip -s 0 원본.zip --out 새롭게만들파일이름

  • -s 0 --out 명령어는 분할을 끄고 단일 파일로 변환하는 옵션이다
  • 참고
Using --out (output to new archive):
  --out oa  output to new archive oa
  Instead of updating input archive, create new output archive oa.
  Result is same as without --out but in new archive.  Input archive
  unchanged.
      WARNING:  --out ALWAYS overwrites any existing output file
  For example, to create new_archive like old_archive but add newfile1
  and newfile2:
    zip old_archive newfile1 newfile2 --out new_archive
  Cannot update split archive, so use --out to out new archive:
    zip in_split_archive newfile1 newfile2 --out out_split_archive
  If input is split, output will default to same split size
  Use -s=0 or -s- to turn off splitting to convert split to single file:
    zip in_split_archive -s 0 --out out_single_file_archive
      WARNING:  If overwriting old split archive but need less splits,
                old splits not overwritten are not needed but remain
  1. zz.zip 파일이 생성되면 finder에서 압축해제가 가능하다

https://linuxconfig.org/how-to-split-zip-archive-into-multiple-blocks-of-a-specific-size