Grep into a file + show following lines

Hi guys,
This is probably very easy but I've no idea how to pull this out.

Basically, I need to find errors into a very large logfile. When you grep the ID, the output is like this:

 +- Type: 799911 Code:  Ret: 22728954 Mand: X Def:  Des:  UserDes:  SeqNo: 2
  +- Type: 799911 Code:  Ret: 22728954 Mand: X Def:  Des:  UserDes:  SeqNo: 2
  +- Type: 799911 Code:  Ret: 22728954 Mand: X Def:  Des:  UserDes:  SeqNo: 2
  +- Type: 799911 Code:  Ret: 22728954 Mand: X Def:  Des:  UserDes:  SeqNo: 2

Those are multiple occurrences of the same action.
What I need to do is to take only one of these results (because they are identical) and show the next 30 lines in the file, starting from the grep line, to highlight the error.

Is it doable?
Thank you :slight_smile:

grep ID file | sort -u
awk '/ID/ && !A[$0]++' file

Use -A option to grep, if supported.

If -A option is not available, there are ways using sed or awk.

If there are extra spaces between the fields, I guess pamu's suggestion needs a bit modification.

$1=$1 forces records to be reconstituted:

awk '/ID/{$1=$1}!A[$0]++' file
awk '$0 ~ EXPR { N=5 } (N--)>0' EXPR="texttomatch" inputfile
awk '$0 ~ PAT { LPr = NR + NL } LPr > NR' PAT="pattern" NL=30 file