웹사이트 검색

초보자를 위한 Linux bzip2 명령 자습서(예제 6개)


이 페이지에서

  1. 리눅스 bzip2 명령
  2. Q1. bzip2를 사용하여 파일을 압축하는 방법은 무엇입니까?\n
  3. Q2. bzip2를 사용하여 여러 파일을 압축하는 방법은 무엇입니까?\n
  4. Q3. bzip2를 사용하여 압축을 푸는 방법은 무엇입니까?\n
  5. Q4. bzip2가 입력 파일을 삭제하지 않게 만드는 방법은 무엇입니까?\n
  6. Q5. 각 압축 작업에 대한 bzip2 표시 세부 정보를 만드는 방법은 무엇입니까?\n
  7. Q6. 압축 파일의 무결성을 확인하는 방법은 무엇입니까?\n
  8. 결론

파일 압축은 container.style.width=100%;var ins=document.createElement(ins);ins.id=slotId+-asloaded;ins.className=adsbygoogle ezasloaded;ins.dataset.adClient=pid;ins에 따라 수행됩니다. .dataset.adChannel=cid;if(ffid==2){ins.dataset.fullWidthResponsive=true;}

리눅스 bzip2 명령어

bzip2는 압축 프로세스를 수행하기 위해 Burrows-Wheeler 블록 정렬 텍스트 압축 알고리즘과 Huffman 코딩을 사용하는 Linux의 명령줄 기반 파일 압축기입니다. 구문은 다음과 같습니다.

bzip2 [OPTIONS] filenames ...

다음은 이 도구에 대한 매뉴얼 페이지의 내용입니다.

       bzip2  compresses  files  using  the Burrows-Wheeler block sorting text
       compression algorithm, and Huffman coding.   Compression  is  generally
       considerably   better   than   that   achieved   by  more  conventional
       LZ77/LZ78-based compressors, and approaches the performance of the  PPM
       family of statistical compressors.

       The  command-line options are deliberately very similar to those of GNU
       gzip, but they are not identical.

       bzip2 expects a list of file names to accompany the command-line flags.
       Each  file is replaced by a compressed version of itself, with the name
       "original_name.bz2".  Each compressed file has  the  same  modification
       date,  permissions,  and, when possible, ownership as the corresponding
       original, so that these properties can be correctly restored at  decom?
       pression  time.  File name handling is naive in the sense that there is
       no mechanism for preserving original file  names,  permissions,  owner?
       ships  or dates in filesystems which lack these concepts, or have seri?
       ous file name length restrictions, such as MS-DOS.

다음은 bzip2 명령이 작동하는 방식에 대한 좋은 아이디어를 제공하는 Q&A 형식의 예입니다.

Q1. bzip2를 사용하여 파일을 압축하는 방법은 무엇입니까?

기본 사용법은 매우 간단합니다. 압축할 파일을 bzip2 명령에 대한 입력으로 전달하기만 하면 됩니다. 예를 들면 다음과 같습니다.

bzip2 list.txt

다음 스크린샷은 실행 중인 명령을 보여줍니다.

Q2. bzip2를 사용하여 여러 파일을 압축하는 방법은 무엇입니까?

단순함 - 파일 이름을 입력으로 전달하기만 하면 됩니다. 다음 예를 참조하십시오.

bzip2 list.txt list1.txt list2.txt

Q3. bzip2를 사용하여 압축을 푸는 방법은 무엇입니까?

압축을 풀려면 -d 명령줄 옵션을 사용하십시오. 예를 들면 다음과 같습니다.

bzip2 -d list.txt.bz2

Q4. bzip2가 입력 파일을 삭제하지 않게 만드는 방법은 무엇입니까?

기본적으로 bzip2는 파일을 압축할 때 원본(또는 입력) 파일을 삭제합니다. 그러나 그렇게 하지 않으려면 -k 명령줄 옵션을 사용하십시오.

다음은 예입니다.

Q5. 각 압축 작업에 대한 bzip2 표시 세부 정보를 만드는 방법은 무엇입니까?

이것은 -v 명령줄 옵션을 사용하여 수행할 수 있습니다. 매뉴얼 페이지에서 설명하는 방법은 다음과 같습니다.

-v --verbose
              Verbose  mode -- show the compression ratio for each file processed.  Further -v's
increase the verbosity level, spewing out lots of information which is primarily of
interest for diagnostic purposes.

다음은 -v를 사용할 때 bzip2 명령 출력을 보여주는 예입니다.

Q6. 압축 파일의 무결성을 확인하는 방법은 무엇입니까?

bzip2 명령은 .bz2 파일의 무결성을 확인하는 데에도 사용할 수 있습니다(파일이 손상되지 않았는지 또는 생성된 이후 변경되었는지 확인하는 테스트). 이것은 -t 명령줄 옵션을 사용하여 수행할 수 있습니다.

-t --test
     Check  integrity of the specified file(s), but don't decompress them. 
This really performs a trial decompression and throws away the result.

결론

bzip2 명령줄 유틸리티는 더 많은 옵션을 제공하지만 여기에서 논의한 내용은 시작하기에 충분해야 합니다. 이 튜토리얼에서 논의한 옵션 연습을 마치면 도구 매뉴얼 페이지로 이동하여 자세히 알아볼 수 있습니다.