假设我有以下内容file.txt
:
asiub
sj
abq
b aia
ainp oo
test = 123d
sub ,.
aiba 87ab
test = 129szs bq
test = aqua
ayqvq 133s
我只想打印file.txt
包含 string的行test =
。
期望output.txt
:
test = 123d
test = 129szs bq
test = aqua
有什么建议吗?
谢谢
答案1
grep "test =" file.txt > output.txt
要仅匹配行开头的字符串,请使用
grep "^test =" file.txt > output.txt