Search

240822_1449_리눅스 압축 및 압축 풀기 명령어

Zip 압축

1.
단일 파일 압축
명령어: zip 압축파일이름.zip 파일이름
예시: zip archive.zip example.txt
결과: example.txt 파일이 archive.zip으로 압축됨
2.
여러 파일 압축
명령어: zip 압축파일이름.zip 파일1 파일2
예시: zip archive.zip file1.txt file2.txt
결과: file1.txtfile2.txtarchive.zip으로 압축됨
3.
디렉토리 전체 압축
명령어: zip -r 압축파일이름.zip 디렉토리이름
예시: zip -r archive.zip myfolder/
결과: myfolder 디렉토리 전체가 archive.zip으로 압축됨
4.
압축 레벨 지정
명령어: zip -r -9 압축파일이름.zip 디렉토리이름
예시: zip -r -9 archive.zip myfolder/
결과: 가장 높은 압축률로 myfolder가 압축됨 (9는 최고 압축률)

주요 옵션

r: 디렉토리 내의 모든 파일과 하위 디렉토리를 재귀적으로 압축
9: 최고 압축률로 압축
e: 암호를 걸어 압축 (zip -e 압축파일이름.zip 파일이름)

Zip 압축 풀기

1.
기본 압축 해제
명령어: unzip 압축파일이름.zip
예시: unzip archive.zip
결과: archive.zip 파일이 현재 디렉토리에 압축 해제됨
2.
특정 디렉토리에 압축 해제
명령어: unzip 압축파일이름.zip -d 디렉토리이름
예시: unzip archive.zip -d /path/to/directory
결과: 압축 파일이 /path/to/directory 디렉토리에 압축 해제됨
3.
압축 해제 전에 내용 확인
명령어: unzip -l 압축파일이름.zip
예시: unzip -l archive.zip
결과: 압축 파일의 내용 목록을 보여줌 (압축 해제하지 않음)
4.
기존 파일 덮어쓰지 않기
명령어: unzip -n 압축파일이름.zip
예시: unzip -n archive.zip
결과: 기존 파일이 있으면 덮어쓰지 않고, 없는 파일만 압축 해제

주요 옵션

l: 압축 파일 내용 목록을 출력
d: 지정한 디렉토리에 압축 해제
n: 기존 파일 덮어쓰지 않음

안녕하세요

한국전자기술연구원 김영광입니다.
관련 기술 문의와 R&D 공동 연구 사업 관련 문의는 “glory@keti.re.kr”로 연락 부탁드립니다.

Hello

I'm Yeonggwang Kim from the Korea Electronics Research Institute.
For technical and business inquiries, please contact me at “glory@keti.re.kr”