Commonly used commands embedded development

grep command

Usage: grep [option] PATTERN [FILE ...]

E.g:

  • Find file contains "request_irq" word in the kernel directory

    grep "request_irq" * -R

    Note: * indicates Find all files in the current directory, directory, -R represents a recursive search subdirectories;

  • In the kernel directory to find the kernel contains "request_irq" word file

    grep "request_irq" kernel -R

    Note: kernel represents the current directory to find the next subdirectory under the kernel, -R represents a recursive search all of its catalog;

find command

Usage: find [-H] [-L] [-P] [path ...] [expression]

E.g:

  • Find in kernel directory file name contains "fb" word file

    find -name "*fb*"

  • Find in kernel drivers / net directory file name contains the word "fb" file

    find drivers/net -name "*fb*"

    NOTE: drivers / net must be the first argument of the find command;

tar command

The command has packing, unpacking, compression and decompression four kinds of functions, common compression, decompression two ways: gzip and bzip2;

In general, in order to ".gz", "z" at the end of the file is compressed, time to ".bz2" files ending is compressed with bzip2 way, the suffix has "tar" the words expressed in the way gzip this is a file package;

tar command has five commonly used options:

Options Features
c Create, and used to generate package
x Represent extract, extract files from file package
with Treated with gzip embodiment, it "c" represents binding to compression, and "x" indicates binding to decompress
j Treated with bzip2 embodiment, it "c" represents binding to compression, and "x" indicates binding to decompress
f Represent files, followed by a file name
diff and patch command

diff command used to compare files, directories, can also be used to make the patch file;

Common options are as follows:

Options Features
-u Output context indicates some of the same line in the comparison result, which facilitates manual positioning
-r File on a comparison of the various subdirectories recursively
-N The file does not exist as an empty file
-w Ignore spaces in comparison
-B Ignore comparison of blank lines

E.g:

Suppose linux-2.6.22.6 directory is the original core, linux-2.6.22.6_ok directory is modified kernel can be prepared using the following command patch file linux-2.6.22.6_ok.diff (first original directory, modified after directory) command is as follows:

diff -urNwB linux-2.6.22.6 linux-2.6.22.6_ok > linux-2.6.22.6_ok.diff

Due to linux-2.6.22.6 is a standard code that can be freely downloaded from the Internet, to be published in the modified linux-2.6.22.6_ok done, only need to provide a patch file linux-2.6.22.6_ok.diff (usually small of);

patch command is used to patch, patch file is based on modifying the original file;

Examples of the above example, the following command can be used to patch file linux-2.6.22.6_ok.diff applied to the original directory linux-2.6.22.6 assumed linux-2.6.22.6_ok.diff and linux-2.6.22.6 in the same directory, the command is as follows:

cd linux-2.6.22.6
patch -p1 < ../linux-2.6.22.6_ok.diff

patch command of the most important option is "-pn", the patch file specified in the path of the file you want to modify, "- pn" before the directory path of ignoring the n slash indicates;

Guess you like

Origin www.cnblogs.com/dongzhuangdian/p/11366824.html