About the selection command grep

grep: It
is to analyze a line of information. If there is the information we need, take that line out. The simple syntax is like this:

		grep [-acinv] [--color=auto] '查找字符' filename
		选项与参数:
		-a:将二进制文件以文本文件的方式查找数据。
		-c:计算找到‘查找字符’的次数。
		-i: 忽略大小写的不同,所以大小写是为不同
		-n:顺便输出行号。
		-v: 反向选择,亦即显示出没有‘查找字符’内容的那一行。
		--color=auto:可以将找到的关键字部份加上颜色的显示。
		例一:将last当中,有出现root的那一行就显示出来。
		last | grep ‘root’
		例二:与范例一相反,只要没有root的就取出
		last | grep -v 'root'

grep is a great command, it supports too much syntax, grep can parse a line of text, get keywords, if there are keywords in the line, it will be listed on the whole line

Published 53 original articles · praised 16 · visits 2213

Guess you like

Origin blog.csdn.net/m0_37757533/article/details/102887849