Yes, you can invoke sed inside awk , and yes, you can invoke awk inside awk ; but there is very seldom any reason to do so.
You have already been shown several ways to do what you requested in your original post. So, I assume you must want to do something more than you have shown us.
Please explain what you're trying to do. Show us some sample input and what output you're trying to produce (using CODE tags). Show us the code you have tried and explain what it isn't doing that you want it to do.
MONDAY###SELECT BLAH,BLAH,... FROM TABSCHEMA1.TABNAME1 WITH UR
SUNDAY###SELECT BLAH,BLAH,... FROM TABSCHEMA2.TABNAME2 WHERE BLAH=1 WITH UR
Like
cat <File name> | awk -F###<......>
if Day = Monday
then
We need to get TABSCHEMA1 and TABNAME1 in separate variables
Later
We use those variable again in other statement
fi
we are doing an awk on each line and inside that awk , we are checking Day Condition and if that Matches we need to get TABSCHEMA1.TABNAME1 and TABSCHEMA2.TABNAME2
cat <File name> | awk -F###<......>
if Day = Monday
then
We need to get TABSCHEMA1 and TABNAME1 in separate variables
Later
We use those variable again in other statement
fi
Which parts of this are actually in the awk script?
Do you need the schema and table names only inside awk, or are you using them later in the shell script? Does your awk script need to produce anything apart from the table/schema names?
Another way in Perl language. Just for alternative solution,
#!/usr/bin/perl -w
# Usage: perl regex.pl file.log
use strict;
my $file = shift;
my $fh = undef;
open ($fh, '<', $file) or die $!;
while (<$fh>)
{
chomp;
print "$1\n" if ($_ =~ /.*?FROM\s+(\S+)\s+.*/)
}
__DATA__
SELECT BLAH,BLAH,... FROM TABSCHEMA1.TABSCHEMA1 WITH UR
SELECT BLAH,BLAH,... FROM TABSCHEMA2.TABSCHEMA2 WHERE BLAH=1 WITH UR
__RESULT__
TABSCHEMA1.TABSCHEMA1
TABSCHEMA2.TABSCHEMA2