如何在ubuntu中的特定单词匹配之后显示5行与终端
以下是输入文件 test.txt
$cat test.txt
Charlie:Harry:Ram
Charlie:Harry:Ram
Charlie:Harry:Ram
Charlie:Harry:Ram
Charlie:Harry:Ram
Charlie:Harry:Ram
Charlie:Harry:Ram
运行此命令获得5行。
grep Charlie test1|head -5
输出: -
Charlie:Harry:Ram
Charlie:Harry:Ram
Charlie:Harry:Ram
Charlie:Harry:Ram
Charlie:Harry:Ram
我相信以下内容是您想要的,但是您的问题并不特别清楚。请发布更多信息,例如您要搜索的文件部分,如果这没有回答您的问题!
grep -A 5 "Charlie" myfile.txt