본문 바로가기
Programing/Linux

Linux zip 압축하기, 압축풀기 명령어 모음

by 멍멍돌이야 2022. 6. 9.
반응형

리눅스 환경에서는 Command Line으로 명령을 실행합니다.  윈도우에 익숙한 사람, 가끔씩 리눅스를 사용하는 개발자, 명령문찾아서 검색을 쉴세없이 찾아다니는 사람들과 폐쇄망에서 열심히 모바일로 서칭해보고 있는 엔지니어를 위하고 매번 까먹는 나자신을 위하여 ZIP 실행 명령문을 정리하도록하겠습니다.

zip {압축 파일명}.zip {압축할 파일 혹은 디렉토리1} {압축할 파일 혹은 디렉토리2}...

 

zip 옵션

  • -f   freshen: only changed files
  • -u   update: only changed or new files
  • -d   delete entries in zipfile
  • -m   move into zipfile (delete OS files)
  • -r   recurse into directories
  • -j   junk (don't record) directory names
  • -0   store only
  • -l   convert LF to CR LF (-ll CR LF to LF)
  • -1   compress faster
  • -9   compress better
  • -q   quiet operation
  • -v   verbose operation/print version info
  • -c   add one-line comments
  • -z   add zipfile comment
  • -@   read names from stdin
  • -o   make zipfile as old as latest entry
  • -x   exclude the following names
  • -i   include only the following names
  • -F   fix zipfile (-FF try harder)
  • -D   do not add directory entries
  • -A   adjust self-extracting exe
  • -J   junk zipfile prefix (unzipsfx)
  • -T   test zipfile integrity
  • -X   eXclude eXtra file attributes
  • -!   use privileges (if granted) to obtain all aspects of WinNT security
  • -$   include volume label
  • -S   include system and hidden files
  • -e   encrypt
  • -n   don't compress these suffixes
  • -h2  show more help

 

 unzip 옵션

  • -a : 압축 해제 텍스트 파일을 기본적으로 자동 변환
  • -L : 파일 이름을 대문자 시스템에서 소문자로 변환
  • -C : 대소 문자를 구분하지 않고 이름을 일치시킴
  • -o : 항상 파일을 덮어쓰기
  • -n : 파일을 추출할 때 파일을 덮어쓰지 않음

  

■ 파일 압축하기

특정 디렉토리에 모든 파일(./*)를 test.zip으로 압축한다.

zip test.zip ./*

 

 파일 및 디렉토리 압축하기

현재 폴더에 여러 하위 폴더가 있는데, 그것도 다 같이 압축하기 위해서는 -r 이라는 옵션을 추가한다.
특정 디렉토리에 모든 파일 및 디렉토리(./*)를 test.zip으로 압축한다.

zip -r test.zip ./*

 

■ 디렉토리 이름없이 압축하기

 

zip -j temp.zip ./temp/*

 

 

 zip 압축풀기

zip파일을 압축을 푸는 명령어는 아래와 같다.

unzip {압축 파일명}.zip

 

 파일 압축풀기

test.zip 파일의 압축을 푸는 명령어는 아래와 같다.

unzip test.zip

 

 특정 디렉토리에 파일 압축풀기

test.zip 파일을 /home/devkuma 디렉토리에 압축을 푸는 명령어는 아래와 같다.

unzip test.zip -d /home/devkuma 

 

 

 우분투에서 zip, unzip 설치

zip, unzip이 설치되지 않은 우분투에서는 아래 명령어로 설치할 수 있다.

sudo apt-get install zip unzip

 

 

 

참고: https://araikuma.tistory.com/120 
728x90
반응형

댓글