extraction of perfect text from file.

Hi All,
I have a file of the following format.

<?xml version='1.0' encoding='utf-8'?>
<tomcat-users>
<role rolename="tomcat"/>
<role rolename="role1"/>
<role rolename="manager"/>
<role rolename="admin"/>
<user username="tomcat" password="tomcat" roles="tomcat"/>
<user username="role1" password="user1" roles="role1"/>
<user username="both" password="mgr" roles="tomcat,role1"/>
<user username="admin" password="admin" roles="admin,manager"/>
</tomcat-users>
[

I need to extract the password from the file above. In the above case the passwords are tomcat,user1,mgr and admin.

Can someone please help in extracting only the password from the above file.

Thanks!
nua7

awk -F"\"" '$3 ~ "password="{print $4}' file

Regards

Thanks a lot for all the help!!

Following is the script that i have written, with reference of the same file above.

The script is working fine , except for the last perl statement.It is unable to replcae values from $enpasswds variable in the tomcat-users.xml file.

Can anyone let me know , where I went wrong..?

#!/usr/bin/ksh
passwds=`awk -F"\"" '$3 ~ "password="{print $4}' tomcat-users.xml`
for i in $passwds
do
en_passwds=`/opt/coreservices/tomcat-5.5.9/bin/digest.sh -a sha $i`
perl -i.bak -pe's/(password=").*?"/$1$en_passwds"/' tomcat-users.xml
done

Guys, please help!

I basically want to replace the plain text passwd with the encrypted passwd.

I get the encrypted passwd using the script: /opt/coreservices/tomcat-5.5.9/bin/digest.sh -a sha $i

Please let me know the right command for this. I am goofing up the perl command somewhere.

Thanks!
nua7

It's not allowed to bump up questions. If you bump your thread to the top you're pushing other peoples threads to the board unfairly to the bottom.
Please read our rules.