grep命令及正则表达式
grep:global search regular expression(RE) and print out the line 文本搜索工具,根据用户指定的文本模式对目标文件进行逐行搜索,显示能够被模式所匹配到的行。 基本语法 grep [option] 'PATTERN' file, ... 正则表达式 :是一类字符所书写出的模式(pattern) 元字符 :不表示字符本身的意义,用于额外功能性的描述 此处表达式分为基本正则表达式和扩展正则表达式。 基本正则表达式的元字符 : 字符匹配 :. . : 任意单个字符 grep --color=auto Boot /etc/rc.d/rc.sysinit grep --color=auto 'B..t' /etc/rc.d/rc.sysinit grep --color=auto 'r..t' /etc/passwd []: 指定范围内的任意单个字符 [^]: 指定范围外的任意单个字符 [0-9], [[:digit:]] 数字 [a-z], [[:lower:]] 小写字母 [A-Z], [[:upper:]] 大写字母 [[:alpha:]] 字母 [[:alnum:]] 字母和数字 [[:space:]] 空格 [[:punct:]] 标点符号 alias cgrep='grep --color=auto' cgrep '