grep
    在文件中搜索一个单词
    grep match_pattern file_name
    grep “match_pattern” file_name

    在多个文件中查找
    grep “match_pattern” file1 file2 file3 …

    输出除match_pattern的所有行 (-v选项)
    grep -v “match_pattern” file_name

    标记匹配颜色 (—color=auto选项)
    grep “match_pattern” file_name —color=auto

    使用正则表达式
    grep -E “[1-9]+” file_name

    egrep “[1-9]+” file_name

    只输出文件中匹配到的部分 (-o 选项)
    echo this is a test line. | grep -o -E “[a-z]+.“
    line.

    包含字符串的行数 (-c 选项)
    grep -c “match_pattern” file_name

    输出包含字符串的所在行数 (-n 选项)
    grep -n “match_pattern” file_name

    对多级目录进行递归搜索
    grep “match_pattern” . -r -n