Blog operations 20,190,526

Linux's main directory

           /: Root directory, a computer has only one root directory, it was all starting from the root directory. Such as / etc, start with the root directory to start entering etc directory

           / Root: the system administrator's home directory.

           / Bin: to store a standard Linux tools such as ls, cp, rm and so on. The directory is included in the PATH, use the program without using the directory path

           / Boot: file is used to load the program.

           / Proc: the operating system is running, process information and kernel information, if the CPU, hard disk partitions, memory, information is stored in the directory.

           / Etc: storage system configuration files, such as vsftpd install this software on your system, you want to modify vstpd profile, vstpd the configuration file in / etc / vstpd directory.

          /etc/init.d storage system or start in system V mode service script.

          /etc/xinetd.d: If the service is run by xinetd mode, the script should be placed at the service of this catalog.

          /etc/rc.d: BSD and way to start the script, the NIC as defined open scripts.

          / Etc / X11: X-Windows related to storing configuration files

          / Dev: the main storage and equipment (including peripherals) relevant documents.

          / Home: storing each user's home directory. Each user's settings file, desktop folder, the user data are placed here.

          / Tmp: temporary directory.

          / Bin, / usr / bin: Most system commands are binary file format to save. Average user commands are used in both directories, system core command tool, such as cd, ls, cp, and so in the / bin directory. Such as a Web browser to / usr / bin directory, and can be shared with other users.

          / Sbin, / usr / sbin: store the root user's command file.

          / Usr / local: used to store the software manually installed.

          / Usr / share: a common file storage system.

          / Usr / src: storing kernel source directory.

          / Var: store some frequently changing files.

          / Var / log: log storage system.

          / Opt: where optional procedures.

          / Lib: library file system

          / Lost + found: the file system, an unexpected system crash or accidental shutdown, a number of file fragments generated in this directory.

          / Mnt: hanging stored in the storage device mounted directory.

          / Meia: Some distributions use this folder to mount mobile hard disk, CD / DVD drive those USB interface and so on.

Text processing tool
grep text search tool for the matching check target text line by line in accordance with user-specified "mode", printing of the matched line.
-O display only the matched character string
-v not to display to match the pattern of the row
- n the number of lines matches
the number of rows of statistical matching -c
-i ignore character case
-q silent mode does not output any information
after line -A # #
-B # # front row
of each longitudinal row # # -C
-e achieve a plurality of options grep -e logic or relationship between the 'CAT' -e 'Dog'
-w matches whole words
-E use ERE
-F equivalent fgrep, it does not support regular expressions
regular expression: written by a class of special characters and text characters the mode in which some characters (metacharacters) does not represent a character literal meaning, while a control or wildcard functions.
two categories: basic regular expressions; extended regular expressions (grep -E; egrep)
metacharacters Category: character match , the number of matches, the position of the anchor, the packet

grep -iEv 'databases | schema' does not match to the line databases and display the schema;

基本正则表达式元字符:
\/ 转义
\. 转义 ".\.." \. 就是.的意思
. 任意的单个字符 (在括号里就是 .)
[] 匹配指定范围内的任意单个字符
[^] 匹配指定范围外的任意单个字符

匹配次数: 用在要指定次数字符后面,指定前面字符要出现的次数
.* 任意长度的任意字符
* 匹配前面字符任意次 包括0次
\? 匹配前面字符的0或1次
\+ 匹配前面字符1次或n次
\{n\} 匹配前面字符n次
\{n,\}匹配前面字符最少n次
\{,n\}匹配前面字符最多n次
\{m,n\} 匹配前面字符出现m-n次

如: grep "go\{10\}gle" / o出现十次
go\?gle
"[a-z]\+" a-z 任意一个出现一次或多次

{1,5\} 1-5 个字符
位置锚定: 定位出现的位置
^ 行首锚定,用于模式的行首 "^zhang"
$ 行尾锚定,用于模式的行尾 "zhang$"
^pattren$ 用于模式匹配整行
^$ 空行
^[[:space:]]*$ 空白行 (空格 Tab)
\<或\b 词首锚定,用于单词模式的行首
\>或\b 词尾锚定,用于单词模式的行尾
\<pattern\> 匹配整个单词

分组 : \(\) 将一个或多个字符捆绑在一起,当作一个整体进行处理.
如: \(root\)\+
分组括号中的模式匹配到的内容会被正则表达式引擎记录于内部的变量中,这些变量的命名方式为:\1,\2,\3...
\1 表示从行首起第一个左括号以及与之匹配右括号之间的模式所匹配到的字符
如: \(zhang1\+\(zhang2\)*\) \1 : zhang1\+\(zhang2\)* \2 : zhang2
后向引用:引用前面的分括号中的模式所匹配字符,而非模式本身
或者:\| a\|b a或b \(C\|c\)at Cat或cat
egrep及扩展正则表达式
egrep = grep -E
字符匹配:
. 任意单个字符
.* 任意长度的任意字符
[] 指定范围的字符
[^] 不在指定范围的字符
* 匹配前面的字符任意次
? 0或1次(最多一次)
+ 1次或多次(最少一次)
\{m} 匹配m次
\{m,n} 匹配m-n次

位置锚定:
^ :行首 $ :行尾 \<, \b :语首 \>, \b :语尾 

分组:
() 后向引用:\1, \2, ... 

或者:
'a|b': a或b 'C|cat': C或cat '(C|c)at':Cat或cat

[0-9,a-z] 数字、字母组合;

[0-9,a-z]\{4} 数字、字母组合,匹配4位;

0-9[0-9] 10-99[1-9][0-9] 100-199=1[0-9][0-9] 200-249=2[0-4][0-9] 250-255=25[0-5]

取IP地址:ifconfig ens33 | egrep [0-9]\{1,3}.[0-9]\{1,3}.[0-9]\{1,3}.[0-9]\{1,3} -o | head -n1

Guess you like

Origin www.cnblogs.com/wangyouxiaoli/p/10927704.html