Hi
sed -f /opt/DBACheck.sql.sed /opt/DBACheck.sql > /opt/DBACheck.sql.tmp
mv -f $DBACheck.sql.tmp $DBACheck.sql

where the contents of DBACheck.sql.sed is

{
s%${DBMS_USER}%SYSTEM%g
}
DBACheck.sql is a one line file , that contains line with string DBMS_USER which i want to replace it with SYSTEM.
But on executing i get DBACheck.sql to be an empty file with all its contents erased .

DBACheck.sql -
select granted_role from sys.dba_role_privs where grantee='${DBMS_USER}';

Thanks
Shyamala

Recommended Answers

All 2 Replies

That's really odd... It works OK on my system:

$ sed -f DBACheck.sql.sed DBACheck.sql
select granted_role from sys.dba_role_privs where grantee='SYSTEM';

What version of sed are you using? ( sed --version )

-G

Thanks for the reply gromit .
It finally worked :)
After appending an empty line in DBACheck.sql -
select granted_role from sys.dba_role_privs where grantee='${DBMS_USER}';

I was able to get the desired output

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.