Utl_compress Zip File

Home » Articles » 10g » Here. UTLCOMPRESS: Compress and Uncompress Data from PL/SQL. The UTLCOMPRESS package provides an API to allow compression and decompression of binary data (RAW, BLOB and BFILE).It uses the Lempel-Ziv compression algorithm which is equivalent to functionality of the gzip utility. A simple example of it's use is shown below. UTLCOMPRESS package lets you compress and decompress binary data (RAW, BLOB, and BFILE).: UTLCOMPRESS « System Packages « Oracle PL / SQL.

File Compression

With the enormous amount of enterprise data that is created and stored, there is a pressing need to conserve disk space and optimize data transfer time. There are various tools, utilities, and commands that are used for file compression. Some of the commonly used commands are:
– The compress command
– The gzip command
– The zip command

The compress Command

When compressing a file, the compress command replaces the original file with a new file that has a .Z extension.

The ownership and modification time of the original file remain intact, but the content of the file changes. The amount of compression depends on the type of file you compress. Typically, compression reduces a text file by 50 to 60 percent.

Compressing a File: compress Command

The following example shows you how to compress a file called test.tar.

Here,
– The -v (verbose) option provides information about the percentage of reduction or expansion of each file.
– The compressed file, test.tar.Z, replaces the test.tar file.

Note: When you compress a file that has already been compressed, the file size increases, instead of becoming smaller. Also, when you rename a file that has already been compressed and you run the compress command on it once again, the file size increases, instead of becoming smaller.

Viewing a Compressed File: zcat Command

The zcat command prints the uncompressed form of a compressed file to the standard output.

To view the content of the data.txt.Z compressed file, enter the following command:

Note: The zcat command interprets the compressed data and displays the content of the file as if it were not compressed.

The zcat filename command is functionally identical to the uncompress -c filename command. For example the to view the content of the compressed file data.txt.Z, we can also use the command shown below.

Uncompressing a File: uncompress Command

The uncompress command restores a compressed file to an uncompressed state.

To uncompress the test.tar.Z file and restore it to the test.tar file, enter the following command:

The -v option displays additional messages about the action being performed.

You can use the uncompress command with the -c option to send the content of a compressed file to the stdout, the screen, without changing the compressed .Z file. Otherwise, you can use the pipe ( ) character to send the output of the uncompress command to another program.

You can use the tar command to list the content of the file that the uncompress command is reading.

The dash (-) at the end of the command line indicates that the tar command reads the data from the piped output of the uncompress command rather than a tar file or a disk.

Compressing a File: gzip Command

Alternatively, you can also use the gzip command to compress files.

The gzip command performs the same function as the compress command, but the gzip command generally produces smaller files. For example, to compress a set of files, file1, file2, file3, and file4, enter the following command:

The compressed files have a .gz extension.

Viewing a Compressed File: gzcat Command

The gzcat command displays files that were compressed with either the gzip or compress commands.

To view the data.txt.gz file, use the following command:

Note: The gzcat command does not change the content of the compressed file. The compressed file remains on the disk in the compressed form.

Uncompressing a File: gunzip Command

The gunzip command uncompresses a file that has been compressed with the gzip command.

Type code into generator, click Generate to get password. Some models require entering three special passwords to get code. Phoenix bios password generator Use dogberts methods to receive code (varies by model).

To uncompress the file1.gz file, use the following command:

Compressing and Archiving Multiple Files: zip Command

The zip command compresses and archives multiple files into a single file in one go.

To compress test1 and test2 into the test.zip archive file, enter the following command:

By default, the zip command adds the .zip extension to the compressed archive file if you do not assign a new file name with an extension.

Note: You can run the zip or unzip command on the command line to view a list of options used with each command.

Viewing and Uncompressing Archive Files: unzip Command

The unzip command is used for listing the files and also for extracting the content of a compressed .zip file.

To uncompress the file.zip archive file, use the following command:

I have lots of files in a directory called /disk2/images/. All files are in zip file format, so I am using the following command to extract zip files:
unzip *.zip
The command result into an error which read as follows:
caution: filename not matched
How do I unzip multiple or many zip files under a Linux/Unix-like system?
Linux or Unix-like system use the unzip command to list, test, or extract files from a ZIP archive, commonly found on MS-DOS systems.

The problem with multiple zip files on Linux

Assuming that you have four file in a /disk2/images/ directory as follows:

  1. pictures.zip
  2. visit.zip
  3. data.zip
  4. invoices.zip

Let us verify it with the ls command:
$ ls
Sample outputs:

To unzip all files, enter:
$ unzip *.zip
Sample outputs:

Above error indicate that you used the unzip command wrongly. It means extract invoices.zip, pictures.zip, and visit.zip files from inside the data.zip archive. Your shell expands the command ‘unzip *.zip’ it as follows:
unzip data.zip invoices.zip pictures.zip visit.zip
The solution is pretty simple when you want to unzip the file using the wild card; you have two options as follows.

#1: Unzip Multiple Files Using Single Quote (short version)

Jelly comb bluetooth keyboard pin. The syntax is as follows to unzip multiple files from Linux command line:

Type the following command as follows:
$ cd /disk2/images/
$ unzip '*.zip'
$ ls -l

Note: *.zip is put in between two single quotes so that shell will not recognize it as a wild card character.

#2: Unzip Multiple Files from Linux Command Line Using Shell For Loop (Long Version)

You can also use for loop as follows:

See also
ADVERTISEMENTS