-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Labels
@codezyc
Description
输出行号
grep -n "boo" a_file
反向查找,即显示没有'搜索字符串'内容的那行
grep -v "boo" a_file
统计一共有多少行匹配了
grep -c "boo" a_file
仅显示匹配到的文件名
grep -l "boo" *
匹配忽略大小写
grep -i "BOO" a_file
完全精确匹配
grep -x "boo" a_file
根据正则表达式进行匹配
grep "e$" a_file
grep -E "boots?" a_file
grep -E "boot|boots" a_file
高亮显示匹配内容
grep --color=always "boo" xxx
显示匹配到字符那行的后面n行
grep -A2 "mach" a_file
显示匹配到字符那行的前面n行
grep -B2 "mach" a_file
显示匹配到字符那行的前后n行
grep -C2 "mach" a_file
递归使用grep
grep -r "192.168.1.5" /etc/
强制只输出那些仅仅包含那个整个单词的行
grep -w "boo" 1.txt