Extract word from a line

Hi,

I've searched the forum to get what I wanted but to no avail. Here's the problem I'm facing.

The line is suppose as below:

<INPUT DATABASE ="ORACLE" DBNAME ="UNIX" NAME ="FACT_TABLE" OWNERNAME ="DIPS">

Now I want to extract only FACT_TABLE. The trials are as follows:

awk -F\" '/^ *=/{print $2}' RS=NAME
results into 
UNIX
FACT_TABLE
DIPS
 
sed 's/\(.*\)\(NAME.*\)/\2/g'
results into
NAME ="DIPS">

:frowning:

Please suggest.

-dips

Try this:

sed 's/.* NAME ="\([^"]*\)".*/\1/'
1 Like

Hi Franklin52,

It worked perfectly fine!! Thankyou.

-dips

perl -E '$s = qq(<INPUT DATABASE ="ORACLE" DBNAME ="UNIX" NAME ="FACT_TABLE" OWNERNAME ="DIPS">); print($s =~ m/.*\bNAME\s=["](.*)["]\s.*/);'