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