웹사이트 검색

예제로 설명된 Linux Gunzip 명령


이 페이지에서

  1. Linux gunzip 명령
  2. Q1. gunzip을 사용하여 아카이브를 압축 해제하는 방법은 무엇입니까?\n
  3. Q2. gunzip이 아카이브 파일을 삭제하지 않도록 하는 방법은 무엇입니까?\n
  4. Q3. gunzip이 압축되지 않은 파일을 다른 디렉토리에 넣는 방법은 무엇입니까?
  5. 추가 정보
  6. 결론

우리는 이미 Linux의 gzip 명령어에 대해 논의했습니다. 우선 이 도구는 파일을 압축하거나 확장하는 데 사용됩니다. 압축을 풀기 위해 이 명령은 다음과 같은 방식으로 사용할 수 있는 명령줄 옵션 -d를 제공합니다.

gzip -d [compressed-file-name]

그러나 gzip으로 생성된 아카이브의 압축을 풀거나 확장하는 데 사용할 수 있는 완전히 다른 도구가 있습니다. 문제의 도구는 gunzip입니다. 이 기사에서는 이해하기 쉬운 몇 가지 예를 사용하여 gunzip 명령에 대해 설명합니다. 튜토리얼에 언급된 모든 예제/지침은 Ubuntu 22.04에서 테스트되었습니다.

리눅스 gunzip 명령

이제 gzip -d 또는 gunzip 명령을 사용하여 압축 파일을 복원할 수 있음을 알게 되었습니다. gunzip의 기본 구문은 다음과 같습니다.

gunzip [compressed-file-name]

다음 Q&A 스타일의 예를 통해 도구 작동 방식을 더 잘 이해할 수 있습니다.

Q1. gunzip을 사용하여 아카이브를 압축 해제하는 방법은 무엇입니까?

이것은 매우 간단합니다. 아카이브 파일의 이름을 gunzip의 인수로 전달하기만 하면 됩니다.

gunzip [archive-name]

예를 들어:

gunzip file1.gz

Q2. gunzip이 아카이브 파일을 삭제하지 않도록 하는 방법은 무엇입니까?

알다시피 gunzip 명령은 압축을 푼 후 아카이브 파일을 삭제합니다. 그러나 아카이브를 유지하려면 -c 명령줄 옵션을 사용하면 됩니다.

gunzip -c [archive-name] > [outputfile-name]

예를 들어:

gunzip -c file1.gz > file1

따라서 이 경우 아카이브 파일이 삭제되지 않았음을 알 수 있습니다.

Q3. gunzip이 압축되지 않은 파일을 다른 디렉토리에 넣는 방법은 무엇입니까?

이전 Q&A에서 -c 옵션에 대해 이미 논의했습니다. gunzip이 압축되지 않은 파일을 현재 작업 디렉토리가 아닌 다른 디렉토리에 두도록 하려면 리디렉션 연산자 뒤에 절대 경로를 제공하십시오.

gunzip -c [compressed-file] > [/complete/path/to/dest/dir/filename]

예를 들면 다음과 같습니다.

gunzip -c file1.gz > /home/himanshu/file1

더 많은 정보

gzip/gunzip의 공통 맨페이지에서 가져온 다음 세부 정보는 명령에 대해 더 알고자 하는 사용자에게 도움이 될 것입니다.

       gunzip takes a list of files on its command line and replaces each file
       whose  name ends with .gz, -gz, .z, -z, or _z (ignoring case) and which
       begins with the correct magic number with an uncompressed file  without
       the  original extension.  gunzip also recognizes the special extensions
       .tgz and .taz as shorthands for .tar.gz and .tar.Z respectively.   When
       compressing, gzip uses the .tgz extension if necessary instead of trun
       cating a file with a .tar extension.

       gunzip can currently decompress files created by gzip,  zip,  compress,
       compress  -H  or pack.  The detection of the input format is automatic.
       When using the first two formats, gunzip checks a 32 bit CRC. For  pack
       and gunzip checks the uncompressed length. The standard compress format
       was not designed to allow consistency checks. However gunzip  is  some
       times  able  to  detect  a bad .Z file. If you get an error when uncom
       pressing a .Z file, do not assume that the .Z file  is  correct  simply
       because the standard uncompress does not complain. This generally means
       that the standard uncompress does not check its input, and happily gen
       erates  garbage  output.   The  SCO compress -H format (lzh compression
       method) does not include a CRC but also allows some consistency checks.

결론

기본 사용법에 관한 한 Gunzip과 관련된 학습 곡선이 많지 않습니다. 우리는 초보자가 이 명령을 사용하기 위해 배워야 하는 거의 모든 것을 다루었습니다. 자세한 내용은 매뉴얼 페이지를 참조하십시오.