The basic use of tar command operation file in Linux

Time:2020-1-5

grammar
     tar [-] A –catenate –concatenate | c –create | d –diff –compare |

         –delete | r –append | t –list | –test-label | u –update | x

         –extract –get [options] [pathname…]

describe
The original official saying is that tar stores or extracts archives on tapes and hard disks.

Functional options
    -a,–catenate,–concatenate
Add files to archive
    -c, –create
Create tar file
    -d,–diff,–compare
Find the difference between archive and current file
    -x,–extract,–get
Unzip Archive

Other options
    -C,–directory
Change directory
    -f,–file ARCHIVE
Specify file or archive
    -j,–bzip2
    -O,–to-stdout
    -z,–gzip,–gunzip,–ungzip
    -v,–verbose
Detailed list of processed files

Usage example
Compress to gzip file:

Copy code

The code is as follows:

tar -zcvf shell.tar.gz shell/

Unzip the gzip file:

Copy code

The code is as follows:

tar -zxvf shell.tar.gz

Compress to bz2 file:

Copy code

The code is as follows:

tar -jcvf shell.tar.bz2 shell/

Unzip the bz2 file:

Copy code

The code is as follows:

tar -jxvf shell.tar.bz2

If you just want to type the file as a tar package without compression, it’s also very simple:

Copy code

The code is as follows:

tar -cvf shell.tar shell/

Also, unzip and you will know:

Copy code

The code is as follows:

tar -xvf shell.tar

Recommended Today

Performance test after class notes (1) basic concepts of performance test

I. real meaning and work content of performance test At first, I thought that performance testing was justDo some scripting, parameterization, correlation, press it up, and then throw a result. But in fact, not only these contents, but alsoPerformance analysis focuses on the improvement of response time, TPS and resource savings after tuning The direction […]