浏览 1702 次
锁定老帖子 主题:shell grep 持续更新
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
|
|
---|---|
作者 | 正文 |
发表时间:2011-11-16
grep -E 'stra|strb' // 查找即包含stra或strb的行 grep ^str // 查找以str开头的行 grep -i str // 忽略大小写 grep -rl str /root // 在/root下查找包含str的文件,并只列出文件名 -r表示递归目录匹配 grep -n str // 显示行号 grep --color str // 染成红色或加重 grep -e // 将两个表达式连在一起,比如:grep -e ^str1 -e str2$ ???? 附: [abc] A single character: a, b or c [^abc] Any single character but a, b, or c [a-z] Any single character in the range a-z [a-zA-Z] Any single character in the range a-z or A-Z ^ Start of line $ End of line \A Start of string \z End of string . Any single character \s Any whitespace character \S Any non-whitespace character \d Any digit \D Any non-digit \w Any word character (letter, number, underscore) \W Any non-word character \b Any word boundary character (...) Capture everything enclosed (a|b) a or b a? Zero or one of a a* Zero or more of a a+ One or more of a a{3} Exactly 3 of a a{3,} 3 or more of a a{3,6} Between 3 and 6 of a options: i case insensitive m make dot match newlines x ignore whitespace in regex o perform #{...} substitutions only once 在线测试:http://www.rubular.com/ 声明:ITeye文章版权属于作者,受法律保护。没有作者书面许可不得转载。
推荐链接
|
|
返回顶楼 | |