웹사이트 검색

예제로 설명하는 Linux bzcmp, bzdiff, bzmore, bzless 및 bzgrep 명령


이 페이지에서

  1. Linux bzcmp, bzdiff, bzmore, bzless 및 bzgrep 명령
    1. Q1. bzcmp 및 bzdiff 명령은 어떻게 작동합니까?\n
    2. Q2. bzmore 및 bzless 명령은 어떻게 작동합니까?\n
    3. Q3. bzgrep 명령은 어떻게 작동합니까?\n

    bzip2 명령줄 유틸리티를 사용하여 파일을 압축할 수 있지만 압축을 풀 필요 없이 파일 비교와 같은 기본 작업을 수행할 수 있는 다른 많은 도구가 있습니다. 이 자습서에서는 이해하기 쉬운 몇 가지 예를 사용하여 bzcmp, bzdiff, bzmore, bzless 및 bzgrep 명령의 기본 사항에 대해 설명합니다.

    그러나 그 전에 이 기사의 모든 예제가 Ubuntu 18.04 LTS 시스템에서 테스트되었음을 언급할 가치가 있습니다.

    Linux bzcmp, bzdiff, bzmore, bzless 및 bzgrep 명령

    Q&A 스타일의 프레젠테이션을 사용하여 이러한 각 명령에 대해 자세히 설명합니다.

    Q1. bzcmp 및 bzdiff 명령은 어떻게 작동합니까?

    이름에서 알 수 있듯이 이러한 명령은 .bz2 파일을 비교하는 데 사용됩니다. 다음은 구문입니다.

    bzcmp [ cmp_options ] file1 [ file2 ]
    bzdiff [ diff_options ] file1 [ file2 ]

    그리고 매뉴얼 페이지가 그들에 대해 말하는 내용은 다음과 같습니다.

           Bzcmp  and  bzdiff  are  used  to invoke the cmp or the diff program on
           bzip2 compressed files.  All options specified are passed  directly  to
           cmp  or diff.  If only 1 file is specified, then the files compared are
           file1 and an uncompressed file1.bz2.  If two files are specified,  then
           they  are  uncompressed  if necessary and fed to cmp or diff.  The exit
           status from cmp or diff is preserved.

    다음은 bzcmp 및 bzdiff의 기본 예입니다.

    bzcmp file1.bz2 file2.bz2
    bzdiff file1.bz2 file2.bz2

    다음 스크린샷은 이러한 명령으로 생성된 출력을 보여줍니다.

    이러한 명령은 명령줄 옵션을 명시적으로 제공하지 않지만 diff 명령의 옵션을 사용할 수 있습니다(이러한 도구는 bzcmp 및 bzdiff 명령에 의해 내부적으로 호출되기 때문입니다).

    Q2. bzmore 및 bzless 명령은 어떻게 작동합니까?

    more and less와 마찬가지로 bzmore와 bzless는 모두 CRT 보기용 필터이지만 압축된 bz2 파일용입니다. 더 나은 아이디어를 제공하기 위해 매뉴얼 페이지에서 bzmore에 대한 발췌문을 제공합니다.

           Bzmore is a filter which allows examination of compressed or plain text
           files one screenful at a time on a soft-copy terminal.  bzmore works on
           files  compressed with bzip2 and also on uncompressed files.  If a file
           does not exist, bzmore looks for a file of the same name with the addi?
           tion of a .bz2 suffix.

           Bzmore  normally  pauses after each screenful, printing --More-- at the
           bottom of the screen.  If the user then types a  carriage  return,  one
           more line is displayed.  If the user hits a space, another screenful is
           displayed.  Other possibilities are enumerated later.

    물론 이러한 명령을 사용하여 단순히 압축 파일을 볼 수도 있습니다. 예를 들면 다음과 같습니다.

    Q3. bzgrep 명령은 어떻게 작동합니까?

    지금까지 짐작하셨겠지만 bzgrep은 여기에서 설명한 다른 bz 시리즈 명령 라인에서도 작동합니다. 특히 grep이지만 압축 파일용입니다. 다음은 이 명령의 매뉴얼 페이지에서 발췌한 것입니다.

           Bzgrep is used to  invoke  the  grep  on  bzip2-compressed  files.  All
           options  specified  are  passed directly to grep.  If no file is speci?
           fied, then the standard input is decompressed if necessary and  fed  to
           grep.   Otherwise the given files are uncompressed if necessary and fed
           to grep.

    다음은 bzgrep의 사용 예입니다.

    bzgrep "menu" file1.bz2

    다음 스크린샷은 출력을 보여줍니다.

    결론

    따라서 압축 파일(.bz2)을 다루고 검색, 비교 등과 같은 기본 작업을 수행하려는 경우 이러한 명령을 사용할 수 있습니다. 여기에서 기본 사항에 대해 논의했습니다. 이러한 도구에 대한 자세한 내용은 매뉴얼 페이지(여기)를 참조하십시오.