One of my most frequently used commands

Posted by Kevin Smith on Oracle Blogs See other posts from Oracle Blogs or by Kevin Smith
Published on Thu, 11 Oct 2012 11:06:51 +0000 Indexed on 2012/10/11 15:43 UTC
Read the original article Hit count: 301

Filed under:

On a Linux or UNIX server this is one of my most frequently used commands.

find . -name "*.htm" -exec grep -iH "alter session" {} \;

It is an easy way to find a string you know is in a group of files, but don't know or can't remember which file it is in.

For the example above, I knew that WebCenter Content sends a bunch of alter session commands to the database when it opens a new database connection. I wanted to find where these were defined and what all the alter session commands were.

So, I ran these commands:

cd /opt/oracle/middleware/Oracle_ECM1/ucm/idc/resources/core
find . -name "*.htm" -exec grep -iH "alter session" {} \;

And the results were:

./tables/query.htm: ALTER SESSION SET optimizer_mode = ?
./tables/query.htm: ALTER SESSION SET NLS_LENGTH_SEMANTICS = ?
./tables/query.htm: ALTER SESSION SET NLS_SORT = ?
./tables/query.htm: ALTER SESSION SET NLS_COMP = ?
./tables/query.htm: ALTER SESSION SET CURSOR_SHARING = ?
./tables/query.htm: ALTER SESSION SET EVENTS '30579 trace name context forever, level 2'
./tables/query.htm: ALTER SESSION SET NLS_DATE_FORMAT = ?
./tables/query.htm: alter session set events '30579 trace name context forever, level 2'

I could then go edit the query.htm file and find the include that contained all the ALTER SESSION commands.

© Oracle Blogs or respective owner

Related posts about /Linux