Linux-Unix: Find files / Find in files

Linux: To find files like *.rdf in the path /oracle/erptd/appl:

find /oracle/erptd/appl -type f -name *.rdf -print 2>/dev/null

Note1: .rdf is the extension for Oracle Reports, 

Note2: 2>/dev/null to drive errors to nowhere

Note3: this search is recursive

Unix: to find file “loadjava” starting from the root directory:

find / -name loadjava -print 2>/dev/null

To find .log files older than 30 days:

find . -name "*.log" -mtime +30 -exec ls -l  {} \;

To delete .log files older than 30 days:

find . -name "*.log" -mtime +30 -exec rm {} \;

Linux-Unix: To find files like *.txt which contain the text Greek in the current directory and all sub-directories:

grep -r Greek *notes*.txt

or if this does not work:

find /home/nista -type f -name "*notes*.txt" -print 2>/dev/null -exec ls -l | grep Greek * {\} \;

or

find /home/nista -type f -name "*notes*.txt" -exec grep -l Greek {} \; -print 2>/dev/null

Leave a Reply