Working experience: Linux compresses all files in the current folder

Time:2021-9-3

Working experience: Linux compresses all files in the current folder
The difference between packaging and compression:

Packaging refers to putting multiple files or directories together to form a total package, which is convenient for storage and transmission, but the size does not change. Compression refers to reducing the volume of one or more large files or directories through the compression algorithm to achieve the purpose of compression, which can save storage space. In compression, it is usually packaged first and then compressed;

Simply take it and use it

linux zipCompression. Compress all files in the current folder asa.zip。 What is the command line method.

Zip - R filename.zip folder name

tar

tarThe command can be used to compress and package a single file, multiple files, a single directory, and multiple directories.

Common formats:

Single file compression and packagingtar czvf my.tar file1

Multiple file compression and packagingtar czvf my.tar file1 file2,...

Single directory compression packagingtar czvf my.tar dir1

Multiple directory compression packagingtar czvf my.tar dir1 dir2

Unpack to current directory:tar xzvf my.tar

Other, zip operation

It is generally not recommended that you complete zip, but you must package it as zip from windows

So how to play?

You install onezipMy bag,

install

centos:

Install zip

yum install zip

Install unzip

yum install unzip

ubuntu:

Installation:

apt-get install zip unzip

Usage:

example

Package all files and folders in / home / HTML / as html.zip in the current directory:

zip -q -r html.zip /home/html

If you are in the / home / HTML directory, you can execute the following commands:

zip -q -r html.zip *

Delete the file A.C from the compressed file cp.zip

zip -dv cp.zip a.c

Reference source of this article

www.runoob.com/linux/linux-comm-zi…

This work adoptsCC agreement, reprint must indicate the author and the link to this article

Thank you for your attention