Linux rookie take-off road "VII" file merging, archiving, and compression

Source: Internet
Author: User
Tags echo command

One, file merge operation
1. Overlay symbols and append symbols

A) ">" means to overwrite the contents of the left file with the contents of the right file, and create this file if the right file does not exist.

b) ">>" represents the contents of the left file appended to the right file, if the right file does not exist, create this file

2.echo echo Command

1 Echo "I am a little shame" >t.txt2echo" I am a little ruin ">>tbak.txt

3. File Merging
1 Cat File a file B > file C

4. Number of statistics file lines
1 WC -L file

5. Pipe Break

Pass the result of the left command execution to the right action

1 Command | command

Example: Count the number of rows after merging two files

cat /etc/passwdWC -L

Second, file archiving operations


Tar command

Format:-C Create a new archive

-C go to the specified directory

-v verbose display of processed files

-F Specify an archive or device

-T lists the files in the document package

-X to expand a file from a document package

Usage:

  

1 tar -cvf the document package name. tar source file          // package 2tar -XVF Document package name.  Tar -C Specify expanded location     // unpacking   

Example:

1 tar -CVF test. tar /test/t.txt/test/tbak.txt/test/newtbak.txt2tar -tf test. Tar 3 tar -xvf  test.  Tar -c/test2

third, file compression operation


1.gzip and Gunzip

Gzip and Gunzip, respectively, are compression and decompression

Usage:

1 gzip files to compress 2 gunzip The compressed file to unzip

Example:

1 gzip Tbak.txt 2 gunzip tbak.txt.gz

2.BZIP2 and BUNZIP2

This format usage is exactly the same as Gzip

Example:

1 bzip2 T.txt 2 bunzip2 t.txt.bz2

Iv. File archive Compression operations

That is, when using file archiving operations, adding-Z to the format calls gzip compression

Usage:

1 tar -czvf xxx. Tar // Archive Compression 2 tar -xzvf xxx. tar. GZ / unpacking and unpacking

Example:

1 tar -czvf ww. Tar . GZ t.txt tbak.txt 2 tar -xzvf ww. tar. Gz-c/test2

Note: If you only want to package a directory under a file and not include this directory, you need to work in that directory.

Linux rookie take-off road "VII" file merging, archiving, and compression

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.