How to get the next word which falls just after a keyword?

Hi friends,
i just want to know the command though which i can get the next word which comes just after a particluar keyword. For example:
suppose text.out is file which contains a pl/sql procedure . i want to find out the word which falls just after the "table1" keyword.

Thank you very much in advance

Please do not leave people guessing. Show a representative sample of input, desired output, attempts at a solution and specify what OS and versions are being used.

@Scrutinizer: i have not written any code because i dont know the solution.
suppose a text file contains the following code"

SELECT  
PI.BUS_APPL_KEY_ID, 
A.PORTFO_TIER_KEY_ID, A.PORTFO_TIER_NAT_ID, A.PA_LOAN_NAT_ID, 
A.CARD_PROD_KEY_ID, A.CARD_PROD_NAT_ID
FROM (SELECT DISTINCT 
  TRWBE_ST.PORTFO_TIER_KEY_ID
FROM
 rrdwst00.TRWBE_ALLOC_REDEMPTION_FACT TRWBE_ST where TRWBE_ST.PA_LOAN_NAT_ID !=0)
 as A
inner join  rrdwst00.TRWPI_PA_LOAN_REIMB_FACT PI
on 
A.PA_LOAN_NAT_ID= PI.PA_LOAN_NAT_ID
and A.REBATE_REWARD_ACCT_NAT_ID=124612528 and A.CM_NAT_ID=410822498
 

------
i just want to know command which can tell me what is the next word which comes after the "FROM" keyword?

output should be : "rrdwst00.TRWBE_ALLOC_REDEMPTION_FACT TRWBE_ST "

thanks in advance

There are two FROMs. How do we know which to pick?

@Scrutinizer i want both output i.e
(SELECT and "rrdwst00.TRWBE_ALLOC_REDEMPTION_FACT TRWBE_ST " .. thanks in advance

---------- Post updated 05-07-12 at 05:18 AM ---------- Previous update was 05-06-12 at 11:40 AM ----------

anyone please helppppppppppp

Bumping up posts or double posting is not permitted in these forums.

Please read the rules, which you agreed to when you registered, if you have not already done so.

You may receive an infraction for this. If so, don't worry, just try to follow the rules more carefully. The infraction will expire in the near future

Thank You.

The UNIX and Linux Forums.

 
$ nawk -v RS="" '{for(i=1;i<=NF-1;i++)if($i~/FROM/){print $(i+1)}}' input.txt
(SELECT
rrdwst00.TRWBE_ALLOC_REDEMPTION_FACT

1 Like

@itkamaraj thank you so much
@scrutinizer i am really sorry ..