/
Linux zip/unzip 으로 압축하고 해제하기
Linux zip/unzip 으로 압축하고 해제하기
다른 압축 프로그램 사용법은 linux 용 압축 프로그램 - gzip/gunzip, bzip2/bunzip2, xz 사용법 을 참고하세요.
zip
zip 은 여러 파일을 묶고 압축할 수 있는 유틸리티로 tar 와는 달리 아카이빙과 압축을 같이 할 수 있습니다.
하위 디렉터리 압축
하위 디렉터리를 포함하는 압축 옵션인 -r 을 사용해서 compressed.zip 파일에 /path/to/dir 내용을 압축합니다.
zip -r compressed.zip /path/to/dir
여러 소스 압축
dir1, dir2, file3 세 개의 소스를 압축합니다.
zip -r compressed.zip /path/to/dir1 /path/to/dir2 /path/to/file3
zip 에 내용 추가
이미 존재하는 zip 파일에 새로운 파일 추가합니다.
zip compressed.zip path/to/file
특정 폴더 제외
특정 폴더를 제외하려면 -x 옵션을 사용하며 아래는 .git 폴더는 빼고 압축합니다. (.git 앞뒤에 이 있는걸 주의하세요)
zip -9 -r compressed.zip /path/to/dir -x '*.git*'
unzip
unzip 은 zip 으로 압축된 파일을 푸는 명령어입니다.
압축내 목록 보기
압축을 해제(❌)하지 않고 압축 파일내의 목록만 출력합니다.
unzip -l compressed.zip
압축 해제
현재 폴더에 압축 해제합니다.
unzip compressed.zip
특정 폴더에 해제
압축이 풀릴 대상을 지정하는 -d 옵션을 사용하면 원하는 폴더에 압축을 해제할 수 있습니다.
unzip compressed.zip -d /path/to/put
여러 파일 압축 해제
unzip 은 file globing 을 제대로 지원하지 않아서 다음과 같이 사용할 수가 없습니다.
unzip *.zip -d /path/to/put
여러 파일 압축 해제가 필요할 경우 bash 의 for 함수를 이용해서 간단하게 처리할 수 있습니다.
for i in *.zip; do unzip $i -d /path/to/put;done
주요 옵션
zip
- -r : 디렉터리까지 압축
- -1: 빠른 압축(압축률 ⬇)
- -9: 높은 압축률 (속도 ⬇)
- -e: zip 파일에 암호 설정
- -x: 압축시 파일 제외
unzip
- -d: 지정한 디렉터리에 압축 해제
- -l: 압축 파일내 목록 보기
같이 보기
Ref
, multiple selections available,
Related content
중복된 내용을 제거하는 linux uniq 명령어 사용법
중복된 내용을 제거하는 linux uniq 명령어 사용법
More like this
Linux journalctl 사용법
Linux journalctl 사용법
More like this
MS 엑셀(Excel)에서 UTF-8 로 된 csv 파일 가져오기
MS 엑셀(Excel)에서 UTF-8 로 된 csv 파일 가져오기
More like this
Atlassian application tunnel 로 On-Prem 과 Cloud 연결하기
Atlassian application tunnel 로 On-Prem 과 Cloud 연결하기
More like this
Confluence/Jira Mobile App 은 허용하고 Mobile browser 는 차단하기
Confluence/Jira Mobile App 은 허용하고 Mobile browser 는 차단하기
More like this
Alfred App
Alfred App
More like this