Several important shell commands: diff patch Tar find grep

Source: Internet
Author: User
Tags diff diff patch

Diff diir_1.0/dir_2.0/-urnb > dir_2.0.patch

U:union output file differential information in a merged format

R: Recursive comparison of all files in subdirectories

U: Treats non-existent files as empty files

B: Ignore the differences caused by empty rows

~/dir_1.0$ patch-p1<. /dir_2.0.patch

-p1 means ignoring the path-level component in the patch file: For example, patches are generated in the home directory, and there are dir_1.0/dir_2.0/two directories in the home directory.

When patching into the dir_1.0/directory, I need to ignore the entry level directory.

Tar
==================
Role: Compress, unzip, release, archive files
Usage:
-------------
1. Unzip
TAR-XJVF a.tar.bz2: Extract to current directory in BZ2 format
TAR-XZVF a.tar.gz: Extract to current directory in GZ format

TAR-XJVF A.TAR.BZ2-C/tmp: Extract to/tmp in BZ2 format
TAR-XZVF a.tar.gz-c/tmp: Extracted in GZ format to/tmp


2. Compression
TAR-CJVF a.tar.bz2 Dir1/file: Compresses dir1/and file into a.tar.bz2 in bz2 format
TAR-CZVF a.tar.gz dir1/file: Compress dir1/and file into a.tar.gz in GZ format

grep (supports regular expressions)
============================
Function: In a file, find a string
Usage:
grep ' Apple ' file-nw (in file, full-text match to find the string Apple, find it and print out its line number)
grep ' Apple ' dir/-RHNW (in the dir/directory, full-text match recursively finds the string apple, and then prints out the file name and line number it was located in)
grep ' apple.* ' dir/-rhnw (in the dir/directory, full-text matching recursively looks for a string starting with Apple, and then prints out the file name and line number, note: ' apple.* ' here is a regular expression)

Find
===============
Function: Under the specified directory, locate the file
Usage:
Find dir/-name "apple.c" (a file named apple.c under dir/)
Find dir/-name "*.c" (under dir/, locate the file with the name suffix. C, note: "*.C" here is the shell wildcard)

Several important shell commands: diff patch Tar find grep

Related Article

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.