Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need help in awk scripting 1

Status
Not open for further replies.

naveenrt

Technical User
Mar 23, 2001
53
0
0
US
Hi
i have a file vv whose contents are below

<entries xmi:id="VariableSubstitutionEntry_29" symbolicName="UNIVERSAL_JDBC_DRIVER_PATH" value="${WAS_INSTALL_ROOT}/universalDriver/lib" description="The directory that contains the DB2 Universal JDBC driver license file."/>

I need to extract the symbolicname value and value of value from this line and print it

The result that i want is UNIVERSAL_JDBC_DRIVER_PATH=${WAS_INSTALL_ROOT}/universalDriver/lib

Here is the script i have but donno how to map the 2 variables var1 and var2 to form the above . nay help is greatly appreciated

=========Code=========
while read line
do
echo $line |awk ' BEGIN { FS = "\" "} {split($0,nav,"\" ");
for ( x = 1 ; x <= NF ; ++x )
#{print nav[x] }
{ split(nav[x],opt,"=\"") ;
if ( opt[1] == "symbolicName") {var1=opt[2] ;print var1 }
if ( opt[1] == "value") {var2=opt[2] ; print var2 }
}

} '
done < vv
====================End code=========
========Result ======================
UNIVERSAL_JDBC_DRIVER_PATH
WAS_INSTALL_ROOT/universalDriver/lib

===================================================



cheers
Naveen
 
Hello,

for awk questions, you might get faster and better answers in forum271
(awk versions for various flavours of Unix are quite similar; in general there will be no need to look for an HP-UX solution only.)

But anyways, what about changing these two lines:
if ( opt[1] == "symbolicName") {var1=opt[2] }
if ( opt[1] == "value") {var2=opt[2] ; print var1"="var2 }
 
thanks alot hoinz that worked . Its simple and it did not strike at all

Cheers
Naveen
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top