Hi
can we grep for a word and print the next word of the greped word?
ex:- create or replace function function_name
create function function_name
we should search for word "function" and output next word "function_name" from both lines.
Hi
can we grep for a word and print the next word of the greped word?
ex:- create or replace function function_name
create function function_name
we should search for word "function" and output next word "function_name" from both lines.
$ nawk '{for(i=1;i<NF;i++){if($i~/^function$/){print $(i+1)}}}' test.txt
function_name
function_name
$ cat test.txt
create or replace function function_name
create function function_name
Thanks
it worked.
i changes your code to
awk '{for(i=1;i<NF;i++){if(tolower($i)~/^function$/){print $(i+1)}}}' testsql
to make the search case insensitive
Next time onwards, use the code tag to post the code