Abhi Exp.10
Abhi Exp.10
Abhi Exp.10
10
Date:
Procedure:
File compression helps to reduce file size and share files efficiently. And compressed
files are also easier to copy to remote servers. Also compress older and rarely used
files and save them for future use which helps you conserve disk space.
tar
The tar command is used to create an archive, grouping multiple files in a single file.Its
name comes from the past and means tape archive.
Syntax
This command creates an archive named archive.tar with the content of file1 and file2:
c stands for create. The f option is used to write to file the archive. The v is providing
details of the files that have been archived.
To remove the original files after creating an archive, use the –remove-files flag.
Tar is often used to create a compressed archive, gzipping the archive. This is
done using the z option:
To unarchive a gzipped archive, use gunzip , or gzip -d , and then unarchive it,
but tar -xf will recognize it’s a gzipped archive
Gzip (GNU zip) is a compressing tool, which is used to truncate the file size. By default
original file will be replaced by the compressed file ending with extension (.gz).
compress a file using the gzip compression protocol using the gzip command.
Gzip filename
This will compress the file, and append a .gz extension to it. The original file is
deleted.
To prevent deleting files, you can use the -c option and use output redirection to
write the output to the filename.gz file:
or
Gzip -k filename
There are various levels of compression. The more the compression, the longer it will
take to compress (and decompress). Levels range from 1 (fastest, worst compression)
to 9 (slowest, better compression), and the default is 6.
Gzip -1 filename
Gzip -r a_folder
Gzip -d filename.gz
The compression ratio or how much the original file has compressed, use -l
option Gzip -l filename.gz
Gunzip
The gunzip command is basically equivalent to the gzip command, except the -d option
is always enabled by default.
Gunzip filename.gz
This will gunzip and will remove the .gz extension, putting the result in the
filename file.
decompressed file
Gunzip -k filename.gz
To recursively decompresses all files in a given directory, use the -r option:
Gunzip -r directory
Gunzip -l filename.gz
Result: Successfully executed File compressing mechanisam using tar Gzip and gunzip.