|
|
EDA365欢迎您登录!
您需要 登录 才可以下载或查看,没有帐号?注册
x
) ~6 u1 V0 Z2 F9 A' s- |$ \
Linux egrep命令用于在文件内查找指定的字符串。( p7 R. S* q+ q: I
5 w2 f3 p' T5 a& Kegrep执行效果与"grep-E"相似,使用的语法及参数可参照grep指令,与grep的不同点在于解读字符串的方法。
/ Q" ?3 \& U, V: F9 U5 |! s; d& Q* p) g, }! U) A4 j8 n a
egrep是用extended regular expression语法来解读的,而grep则用basic regular expression 语法解读,extended regular expression比basic regular expression的表达更规范。& y: d5 t5 R$ y& h( Q
& w- |2 k+ a% F4 H' z* l
n6 s1 s1 k6 q& D语法$ I* f1 x# v/ _6 Q
# v$ ^5 I' Z( Z0 U* Gegrep [范本模式] [文件或目录] 0 R; W( X6 o E5 q
, P9 d4 z u# I: d1 V; e) s, N5 X5 {! H0 ^
参数说明:& R. M8 P7 c1 S+ r2 t9 N! H) m
$ D' h2 o# N+ N9 {$ g8 V4 ~
[范本模式] :查找的字符串规则。' m8 e9 A5 k0 v1 _" T1 q
[文件或目录] :查找的目标文件或目录。: L5 \) s! _" n, |+ O$ ^( T: g
/ Z8 c4 \% w7 {5 P; a2 s/ q) @3 G/ ~& T+ s1 I3 s
实例* X% {' r5 W' R1 H2 H4 P( l; `
* G/ e! T- y Y7 O( w显示文件中符合条件的字符。例如,查找当前目录下所有文件中包含字符串"Linux"的文件,可以使用如下命令:; ~: \0 d2 Q0 ~
4 S5 _2 [; c/ P2 R6 e6 ]egrep Linux *
# G3 g4 G: ~ F2 Q9 I4 |! L3 p! L* X, g# u
- v I, l, o# o! a. ]结果如下所示:, ^6 d' @' K$ _, ?
0 ~: W" F+ C, J0 d
$ egrep Linux * #查找当前目录下包含字符串“Linux”的文件 ) S: ^* W2 k6 S$ C& |6 I; s J/ e
testfile:hello Linux! #以下五行为testfile 中包含Linux字符的行 ( ]" h9 _8 U, b* s
testfile:Linux is a free Unix-type operating system.
+ U7 r8 @* M$ n9 Ctestfile:This is a Linux testfile!
3 O: P/ O5 x* a$ b% Stestfile:Linux ; c& P# ]6 p4 m! l( ]0 _ y
testfile:Linux
+ Q: \7 q- t i! V/ otestfile1:helLinux! #以下两行为testfile1中含Linux字符的行
U8 k2 {! [/ b% s! Z' p, Ytestfile1:This a Linux testfile! ! N0 { {0 T8 m1 E: z2 ?
#以下两行为testfile_2 中包含Linux字符的行 2 g) D8 {, y8 ~+ Y6 C5 X1 j; s
testfile_2:Linux is a free unix-type opterating system.
1 Z, a! L g- d. |- etestfile_2:Linux test : X1 S3 s( ?( H2 p2 N/ Y
xx00:hello Linux! #xx00包含Linux字符的行
( i) `2 U' [ [- c& h; n* }xx01:Linux is a free Unix-type operating system. #以下三行为xx01包含Linux字符的行 - K5 e- N1 A- I! \! n/ L. d
xx01:This is a Linux testfile!
: {: Y/ M* X+ j. _) J; \xx01:Linux
# s4 B" [ O' s! P. e& z5 ~" } |
|