Linux High Frequency command (ii)

Source: Internet
Author: User

The tar command can be used to archive and compress files. The GNU version of the Tar Tool room under Linux, this version differs from the traditional tar, such as supporting long format parameters. The syntax for tar is:

Tar < operations > [parameters]

The Operation options are:

[-] A a tar file is appended to another archive file

[-]c Create a new document

[-]d look for differences between archiving and file systems

[-]r adds a file to the end of an archive file

[-]t lists the contents of the archive file

[-]u replaces the updated file with the old file in the original archive

[-]x Unzip the archive file

--delete Remove from archive

Common parameters are as follows:

-f< file name > Use archive

-j using BZIP2 program to compress/unzip archive files

-V Verbose output mode

-Z Compress/Unzip archive files using gzip program

--atime-preserve does not change the file access

Wait a minute......

The following command, archive all files under/home/zhu and compress with gzip, generates a compressed archive file named test.tar.gz:

[Email protected] zhu]# tar Zcvf/tmp/test.tar.gz/home/zhu

The following command unzip the file test.tar.gz

[Email protected] tmp]# tar zxvf test.tar.gz
home/zhu/
home/zhu/.gnome2/
home/zhu/.mozilla/
home/zhu/.mozilla/extensions/
home/zhu/.mozilla/plugins/
Home/zhu/.bash_logout
Home/zhu/hello.txt
Home/zhu/.bashrc
Home/zhu/.bash_profile

Gzip Compression Tool

Gzip is a compression tool that uses the LZ77 algorithm. The syntax is:

gzip [parameters] [filename ... ]

Parameters:

-C directs the output to the standard output, keeping the source file intact

-D Decompression

-F Force Compression or decompression

-l lists the compressed file's compressed size, uncompressed size, compression ratio, and the file name after decompression

-R recursively compress or unzip all files in the directory and sub-directories

-T test

The following example command compresses/TMP/ABC to/tmp/abc.gz:

[Email protected] tmp]# GZIP/TMP/ABC

Note: According to the above operation, the original file is not, if you want to keep the original file can be used

[Email protected] tmp]# gzip-c/tmp/abc >/tmp/abc.gz

Extract:

[Email protected] tmp]# gzip-d/tmp/abc.gz

BZIP2 Compression Tool

Parameters:

-C compress or decompress to standard output

-D Decompression

-Z Compression

-T test

-K Preserve Source files

-< compression speed > Specify compression speed. Compression speed is an integer 1-9

The following example:

[Email protected] tmp]# BZIP2-K9/TMP/ABC

[Email protected] tmp]# bzip2-d/tmp/abc.bz2

Text-processing-related commands

grep displays matching rows in the file

Parameters:

-a< lines > Display matching rows, and the number of rows specified after matching rows

-b< lines > Display matching rows, and the number of rows specified before matching rows

-C Displays the number of matching rows

-e< string > Match Special string

-I ignores case

-N marks the upstream number before the output line

-R recursively reads files in directories and subdirectories

-X outputs only rows that match the entire row

[[email protected] tmp]# grep test/tmp/abc

differ comparing the differences between two files

Parameters:

-A handles all file files as text files

-B ignores the difference in the number of spaces

-B ignores whitespace differences

-I ignores case differences

-Q If two files are different, the report

-R comparing two directories, recursively comparing files in directories and subdirectories

-S If there are no differences between the two files, the report

differ File1 File2

Sort sorted File Contents

Parameters

-F ignores case

-g Sort By value

-I only consider the characters that can be displayed

-k< column number > Sort by specified column number

-n Sort by string value

-R Reverse Sort

-O outputs the finished sorted content to the destination file

-U If there are multiple peers, only one line is output

Head Display file Start section

Parameters:

-c< number of bytes >

-n< Number of lines >

-V

Examples:

[Email protected] tmp]# head-n 5/etc/services
#/etc/services:
# $Id: services,v 1.48 2009/11/11 14:32:31 Ovasik EXP $
#
# Network Services, Internet style
# IANA Services Version:last updated 2009-11-10

Tail show end of file

Parameters above

[Email protected] tmp]# tail-10/etc/services
NIMGTW 48003/UDP # Nimbus Gateway
3gpp-cbsp 48049/tcp # 3GPP Cell broadcast Service Protocol
Isnetserv 48128/tcp # Image Systems Network Services
Isnetserv 48128/udp # Image Systems Network Services
BLP5 48129/TCP # Bloomberg Locator
BLP5 48129/UDP # Bloomberg Locator
COM-BARDAC-DW 48556/tcp # COM-BARDAC-DW
COM-BARDAC-DW 48556/UDP # COM-BARDAC-DW
Iqobject 48619/tcp # Iqobject
Iqobject 48619/UDP # Iqobject

Content information for WC statistics files

Parameters:

-C Display of bytes

-m display number of characters

-l display number of rows

-L Displays the number of characters for the longest line

-W Display number of words

[Email protected] tmp]# wc/etc/services
10774 58104 640999/etc/services

This article is from the "IT Walker Pine" blog, please be sure to keep this source http://520yatou.blog.51cto.com/6642882/1434951

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.