//Part -2 301 redirect -------->

My blog has moved! New blog contains all the entries found in this one.

You should be automatically redirected in 8 seconds. If not, visit
http://srinisboulevard.blogspot.com/
and update your bookmarks.

// End Part -2 301 redirect ------>

Friday, March 07, 2008

Using Unix Find Command

Find:
find . -name "wfstatus.sql" -print
the above command will search all directories starting from current directory for any file containing wfstatus.sql.
Problem: find displays an error message for any directory I do not have permissions.
So how do I suppress these messages?
The following command will do the trick:

find . - name "wfstatus.sql " -print 2> /dev/null
will suppress cannot read dir or Permission denied messages and print only if it finds the file.
Output of this command:
/oracle/prodappl/fnd/11.5.0/sql/wfstatus.sql

explanation:
/dev/null is a virtual file in Unix; data written to is deleted.
I use the cheatsheet from Stanford.edu (to go to stanford clickhere )

In order to do a case-insensitive search, instead of "name", use "iname":
find . -iname "WFSTAtus.sql" -print 2>/dev/null

if you want the search to be restricted only to files, then use "-type f"
find . -type f -iname "WFSTAtus.sql"   -print 2>/dev/null

No comments: