-1

how to Show 5 lines after the match of a specific word like "Charlie" in ubuntu with terminal

James
  • 1

2 Answers2

0

Below is the input file 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

Run this command to get 5 lines.

grep Charlie test1|head -5

output:-

Charlie:Harry:Ram
Charlie:Harry:Ram
Charlie:Harry:Ram
Charlie:Harry:Ram
Charlie:Harry:Ram
sumitya
  • 2,631
  • 1
  • 19
  • 32
  • not like that gege gege Charlie a b c d e f this is the input and the out put comes like a b c d e f inshort after charlie 5 line comes @syadav – James Jun 15 '16 at 18:58
0

I believe the following is what you're looking for, but your question is not particularly clear. Please post more information, such as a section of the file you're searching in if this doesn't answer your question!

grep -A 5 "Charlie" myfile.txt

ti7
  • 16,375
  • 6
  • 40
  • 68