Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to compress and decompress tar

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article will explain in detail how to compress and decompress tar. The content of the article is of high quality, so the editor will share it for you as a reference. I hope you will have a certain understanding of the relevant knowledge after reading this article.

Format: tar zcvf compressed path and package name of the file you want to compress

Z:gzip compression

C: create a compressed package

V: displays the process of package compression and decompression

F: then compress

T: view the contents of the package

X: decompression

X: specify the file list form to exclude files or directories that do not need to be packaged and compressed

-exclude: specify files or directories that do not need to be packaged and compressed (you can also use regular matching / wildcards, etc.)

-C: extract to the specified directory

For example, compress the file under / root/cs/test/ into the file / root/cs/test1 and name it 1.

Tar zcf / root/cs/test1/1.tar.gz / root/cs/test/

When compressing, prompt:

Tar: removes the first "/" from the member name

At this point, add the parameter P to eliminate the prompt. But the P parameter is also needed when decompressing.

Check what's in the package:

Tar tf. / 1.tar.gz

Note: when packing, try to switch to one level above the packaged directory and then pack.

If you exclude multiple files:

Method 1: add the exclusion file after the parameter:-- exclude= exclude file name 1 / exclude file name 2.

Method 2: create an exclusion file, put what needs to be excluded into the file, and exclude it through the command parameter X

Compress the file under / root/cs/test/ into the / root/cs/test1 file and name it 2 (package compression excluding access_www_2018-10-04.log file)

Tar zcfP / root/cs/test1/2.tar.gz-- exclude=access_www_2018-10-04.log / / need to exclude multiple followed-exclude= files or directories (wildcard / regular matching can also be used)

Method 2: set up the exclusion file and package it with the-X parameter

Tar zcvfX / root/cs/test1/3.tar.gz pclb.list. / test/

Extract the 3.tar.gz file under the / root/cs/test1 file to the / root/cs/test1 directory

Tar xvf 3.tar.gz

Extract the 3.tar.gz file under the / root/cs/test1 file to the / tmp/ directory

Tar xvf 3.tar.gz-C / tmp/

In addition, unix systems generally use tar cfp paths / file names. Tar.gz needs the path to be backed up

On how to carry out tar compression and decompression to share here, I hope the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report