728x90
반응형
SMALL
리눅스에서 압축파일을 다룰때 주로 사용하는 tar 명령어에 대한 정리( + zip)
tar
- tar : 테이프 아카이버(Tape ARchiver)의 약자로, 여러개의 파일을 하나로 합치는 용도로 사용
- 확장자 : .tar
- 데이터의 크기를 줄이는 파일 압축은 이루어지지 않음
- tar.gz : tar로 합쳐진 파일을 gzip으로 압축한것
- 확장자 : .tar.gz
- tar로 합친 파일을 압축했기 때문에 데이터의 크기는 줄어듬
명령어
0. tar 명령어 주요 옵션
tar [<옵션>...] [<파일>]...
-c : --create 새 아카이브 생성
-v : --verbose 처리한 파일 목록을 자세하게 내열
-f : --file=<아카이브> 아카이브 파일 또는 대상 지정
-x : --extract, --get 아카이브 파일 추출
-z : --gzip, --gunzip, --ungzip gzip 아카이브 필터링
-t : --list 아카이브 내용 표시
-C: --directory=<디렉터리> 대상 디렉터리 경로 지정
1. tar로 압축
$ tar -cvf [파일명.tar] [폴더명]
$ tar -cvf compress.tar test
test/
test/1.txt
test/2.txt
test/3.txt
2. tar 압축 해제
$ tar -xvf [파일명.tar]
$ tar -xvf compress.tar
new/
new/1.txt
new/2.txt
new/3.txt
$ tar -xvf [파일명] [대상 경로]
$ tar -xvf copress.tar -C ./NEW
test/
test/1.txt
test/2.txt
test/3.txt
3. tar.gz로 압축
$ tar -zcvf [파일명.tar.gz] [폴더명]
$ tar -zcvf copress.tar.gz test
test/
test/1.txt
test/2.txt
test/3.txt
4. tar.gz 압축 해제
$ tar -zxvf [파일명.tar.gz]
$ tar -zxvf copress.tar.gz
test/
test/1.txt
test/2.txt
test/3.txt
$ tar -zxvf [파일명] [대상 경로]
$ tar -zxvf copress.tar -C ./NEW
test/
test/1.txt
test/2.txt
test/3.txt
5. zip으로 압축
$ zip [파일명.zip] [폴더명]
$ zip compress.zip test
6. zip 압축 해제
$ unzip [파일명.zip]
$ unzip compress.zip
728x90
반응형
LIST
'OS > Linux' 카테고리의 다른 글
[Linux] gcc, g++ 컴파일 (0) | 2023.08.30 |
---|