Multiple selective keyword Report

Dear All,
I have a question on what is the best way to control and list out multiple selective keywords to print out the report
Below is the Sample output of the listing

Code1
Code1
Code1
Identifier "Job"
Code2
Code2
Code2
Name "Impressive"
Code3
Code3
Code3
AGT_Manual
Code1
Code1
Code1
Identifier "Findme"
Code2
Code2
Code2
Name "Positive"
Code3
Code3
Code3
Code3
Code3 
Code3
AGT_AUTO
Code1
Code1
Code1
Identifier "Job"
Code2
Code2
Code2
Name "Not Here"
Code3
Code3
Code3
AGT_Manual
Code1
Code1
Code1
Identifier "Findme"
Code2
Code2
Code2
Code2
Code2
Name "Positive"
Code3
Code3
Code3
Code3
Code3
AGT_AUTO

Expected Output 1

[Lineno] : Identifier "Findme"      Name "Positive"    AGT_AUTO
[Lineno] : Identifier "Findme"      Name "Positive"    AGT_AUTO   

Expected Output

[Lineno] : Identifier "Findme"      Name "Positive"   Code3     AGT_AUTO
                                                      Code3
                                                      Code3

[Lineno] : Identifier "Findme"      Name "Positive"   Code3     AGT_AUTO
                                                      Code3
                                                      Code3

Remarks : Lineno : is the rowno of the Identifier "Findme" in the source file
               Code3 only shown top 3 lines 

Thanks for all your time scratching your head to think of the solution.

Hello ckwan,

After 60 posts, I'd hope you could help us out a little here. I have a few to questions pose in response first:-

  • Is this homework/assignment? There are specific forums for these.
  • What have you tried so far?
  • Are the line numbers to display meant to just be sequential in the output or to represent the line it is found in the input?
    [list]
  • Where you have two items found being written on the same output line, which input line would you want it to refer to?
    [/list]
  • What output/errors do you get?
  • What OS and version are you using?
  • What are your preferred tools? (C, shell, perl, awk, etc.)
  • What logical process have you considered? (to help steer us to follow what you are trying to achieve)

Most importantly, What have you tried so far?

There are probably many ways to achieve most tasks, so giving us an idea of your style and thoughts will help us guide you to an answer most suitable to you so you can adjust it to suit your needs in future.

We're all here to learn and getting the relevant information will help us all.

Kind regards,
Robin

2 Likes

In addition to what Robin has already said, we also need a clear English description of what you are trying to do.

It looks like you want to ignore every line of input that does not have "C" as the first character on the line and then look at the remaining lines in groups of three. If the first line of a group is not literally Identifier "Findme" and the second line of a group is not literally Name "Positive" and the third line of a group is not literally AGT_AUTO then that group should also be ignored.

If that is what you're trying to do, I don't understand why producing that output would be important to anyone. It would seem that just knowing how many times a group matched each of those lines in sequence might be much more useful.

Hi Robin,
I can use awk command however cannot achieve the output I wanted. This is for my own interest and this is not assignment.

    awk '/Identifier "Name"/ { print $0; getline;getline;getline; print $0 } /AGT_AUTO/ {print $0 }' listing.out
   

Hi Don,
Imagine I have large file which contains all the mixture data. The main purpose of this is to identify and select only those multiple keywords from the list and tabular out into report.
Another purpose is from the output I can cross check against my original list by using lineno.