Shell to display portion of a line

Thanks a lot for the code and the explanation.

Now my final requirement.

I have uploaded 3 files as attachment. Please open the files in Editplus or any other text editor which keeps the formatting.

GMDCOM.27936.log.txt------I want to pick only Process request from this file.(Please check the fourth line of the file)
e.g: Process Request <36812974>
Search the above process request number (in this case 36812974) in GMDRRS.27895.log.txt file and again search it in GMDRES.28009.log.txt file.

Wherever it matches the above process request in all the 3 files. Please display the same in another file along with date, time and process request number.
It has to be done for all the Process Request number in GMDCOM.27936.log.txt file.

Output to be in the below format.

          Request ID                             GMDCOM                           GMDRRS                    GMDRES
Procs.Req No              Date        Time                 Date                     Time                     Date Time

Hope I am clear with the requirement. If there are any issues, please let me know.

What have you tried so far?

1st I am trying to display all the lines from GMDCOM.27936.log.txt in the below format.

[36812974    [Tue Oct  1 13:32:40 2013]]

How do i display all the records from the file GMDCOM.27936.log.txt in the above format. File is attached in the previous post.

I was trying the below code. but its not working.

cat $file | cut -d ' ' -f 10
awk 'NR==1 { print 36812974:", $1, $2, $3 } ' trial

Could you give a more specific sample of the output that you are looking for?

Sample Input File

[Tue Oct  1 13:28:23 2013]: file reopened from GMDCOM with PID <27936>.
[Tue Oct  1 13:28:23 2013]: GMDCOM: Process <27936> created a running file.
GMDCOM [Tue Oct  1 13:28:24 2013]: DELTA MODE Flag OFF!
GMDCOM.27936 [Tue Oct  1 13:32:40 2013]: Process Request <36812974>
GMDCOM.27936 [Tue Oct  1 13:37:38 2013]: Process Request <36812985>
GMDCOM.27936 [Tue Oct  1 13:37:53 2013]: Process Request <36812986>
GMDCOM.27936 [Tue Oct  1 13:37:54 2013]: Process Request <36812987>
GMDCOM.27936 [Tue Oct  1 13:37:57 2013]: Process Request <36812996>
GMDCOM.27936 [Tue Oct  1 13:38:06 2013]: Process Request <36812998>

I want the output in the below format by skipping the 1st 3 lines

36812974 [Tue Oct  1 13:32:40 2013]
36812985 [Tue Oct  1 13:37:38 2013]
36812986 [Tue Oct  1 13:37:53 2013]

and it goes on like this till the end of the file. How will it display all the records in the above format. Please help.

But that contradicts your previous attempts at output specifications in both posts #1 and posts #3. Please clarify..

The output requirement changed a bit, hence requested for the change in formatting.

OK but which one of the 3 is it? Please do not leave us guessing. Show a representative sample of your desired output or this thread will be closed.

Sample Input File

Code:

GMDCOM.27936 [Tue Oct  1 13:32:40 2013]: Process Request <36812974> GMDCOM.27936 [Tue Oct  1 13:37:38 2013]: Process Request <36812985> GMDCOM.27936 [Tue Oct  1 13:37:53 2013]: Process Request <36812986> GMDCOM.27936 [Tue Oct  1 13:37:54 2013]: Process Request <36812987> GMDCOM.27936 [Tue Oct  1 13:37:57 2013]: Process Request <36812996> GMDCOM.27936 [Tue Oct  1 13:38:06 2013]: Process Request <36812998>

I want the output in the below format.

Code:

36812974 [Tue Oct  1 13:32:40 2013] 36812985 [Tue Oct  1 13:37:38 2013] 36812986 [Tue Oct  1 13:37:53 2013]

and it goes on like this till the end of the file. How will it display all the records in the above format. Please help.

So now the input file is in a different format and the output is format is different yet again.
Closing thread