Code reading and finding tools under Linux __linux

Source: Internet
Author: User
Tags logical operators tagname file permissions

1.ctags

The Ctags command with the VIM editor can help programmers easily view the source code, using the method:

(1) Executing ctags-r * Recursively to establish source code information base under the source code top-level directory;

(2) Vim-t tagname Open the file containing tagname;

In the VIM editor

(3): Tag tagname: Jump to a file containing tagname;

(4): tn: Next tagname;

(5): TP: the former one tagname;

(6): Cstag tagname: List all tagname locations;

In the VIM editor, the cursor moves to a variable

(7) Ctrl +]: Jump to the definition of the variable;

(8) Ctrl + T: Jump back to the original position

2.cscope

Cscope is another useful source view tool, generally speaking, are vim+ctags+cscope combination tools, therefore, the following look at the use of cscope.

(1) Execute CSCOPE-RBKQ in the top level directory of source code

-R: Recursive establishment of information base;

-B: Only cross reference links are established;

-K: Kernel mode (used only when browsing kernel source code);

-Q: Turn on the acceleration function;

The command line can use the cscope-d command to view source code separately using Cscope, or you can import information into vim in the Vim editor, cscope add Cscope.out, and then use the: Cscope help command to view the available features.

3.find

Recursively searches for files in the specified path, supports various conditional searches, and can perform specific actions on the files that are searched.

Basic format: Find [path] [parameters] [expression]

Common parameters:

-user: Find files According to the owner of the document;

-group: Find files based on the group they belong to;

-name: Find files by file name;

-perm: Find files according to file permissions;

-size: Find files based on file size;

-atime N: List the files that have been visited in the n*24 hours;

-ctime N: The n*24 hours are changed, the new file enumerated;

-mtime N: List the files that have been modified within n*24 hours;

-newer file: It will be listed as a new document;

-gid N: Searching for files with group ID n;

-group Name: Search for files with group name;

-uid N: Find the file with the owner ID N;

-name file: Looking for files named file

-type [Bcdpls]: Looking for specific types of files (block devices, character devices, directories, pipelines, links, and sockets)

Find also supports advanced applications, for example, you can use logical operators to write complex conditions, "-o" representations or operations, "-not" to represent non operations, and you can manipulate the found file in the following format:

find [path] [parameter] [expression]-exec instruction {} \;

L {} represents find found File

L \ non-change of meaning

l; Indicates the end of the bank's instruction

4.grep

Using the grep command:

Grep-rni--include ' *. [C|h] ' regex '.

That is, all the. C and. h files in the current directory look for entries that match the regex, where:

-R: means to recursively find the current directory and its subdirectories;

-N: Displays line numbers;

-I: Ignore case;

Can be flexibly adjusted and combined according to the situation.

5. Regular expressions

When writing a program or Web page that handles strings, there is often a need to find strings that match some of the complex rules. Regular expressions are the tools that describe these rules.

Reference:

(1) \b: match the beginning or end of a word, such as "\bhi\b" to match the word "HI";

(2).: Match any character except the line break;

(3) *: The characters in front of the symbol can be repeated several times, such as ". *" to represent any number of characters without line breaks;

(4) \d: Matches a number, \d{num} matches num times number;

(5) \s: Match any whitespace, including spaces, tabs (tab) and line breaks, etc.

(6) \w: Matches the letter or the numeral or the underline or the Chinese character and so on;

(7) +: The character preceding the symbol matches once or several times;

(8) ^: The beginning of the matching string;

(9) $: The end of the matching string;

(10)?: The character preceding the symbol matches 0 times or once;

(one) {n}: repeat n times;

(a) {n,}: Repeat n times or more times;

{n,m}: repeats N to M times;

(14) []: Match any one of these characters, as [aeiou] matches any one of the vowel letters, [2-5] matches 2 to 5 arbitrary numbers;

(15) |: Denotes a branching condition, equivalent to "or"

(\w): matches any character that is not a letter, number, underscore, or character;

(\s): matches any character that is not a blank symbol;

(\d): matches any character that is not a number;

(\b): match is not the beginning or end of the word position;

[^x]: matches any character other than x, such as [^aeiou] matches any character other than the aeiou of these letters;

Example:

\ba\w*\b: Matches a word beginning with A;

\d+: Match 1 or more consecutive digits;

\b\w{6}\b: Matches just six-letter words;

^\d{5,12}$: matches 5 to 12 digits;

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.