读书人

shell 之 grep 继续更新

发布时间: 2012-07-02 17:46:22 作者: rapoo

shell 之 grep 持续更新

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$ ????
grep -B12 str        // 显示str所在行及其前12行
grep -A23 str        // 显示str所在行及其后23行
grep -C34 str        // 显示str所在行及其前后34行


附:

[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\AStart of string\zEnd of string.Any single character\sAny whitespace character\SAny non-whitespace character\dAny digit\DAny non-digit\wAny word character (letter, number, underscore)\WAny non-word character\bAny word boundary character(...)Capture everything enclosed(a|b)a or ba?Zero or one of aa*Zero or more of aa+One or more of aa{3}Exactly 3 of aa{3,}3 or more of aa{3,6}Between 3 and 6 of aoptions: i case insensitive m make dot match newlines x ignore whitespace in regex o perform #{...} substitutions only once



在线测试:http://www.rubular.com/

?

?

刚才从同事那里得到了一张神图,是vi的,顺便贴在这吧

?

?

读书人网 >操作系统

热点推荐