Unix Shell Scripting

Finding file counts
For Linux:

cd $ORACLE_BASE/admin

-- For Linux
find -maxdepth 2 -type d | while read dir; do 
    count=$(find "$dir" -maxdepth 2 -iname \*.aud | wc -l)
    echo "$count ; $dir"
done | grep adump | sort -n

Getting around too many arguments:
This method is scalable, does not have issues with argument list limits, and works well for millions of files. This example looks for files that match *.aud.

for f in *.aud; do rm "$f"; done

You can leverage power of the find command with backticks. This produces a list of files that are fed to the 'do' block one by one.

for f in `find *.aud -mtime +60`; do rm "$f"; done

Finding Large Files Recursively

find / -xdev -type f -size +100M

Delete files older than 60 days
Note: This method can have issues with argument list lengths. It may error out if too many files are fed to the exec command, in this case rm.

find *.aud -mtime +60 -exec rm {} \;

You can combine it with xargs to get around the argument list length limit:

find . -name "*.aud" -mtime +60 -print0 | xargs -0 rm

Grepping Files using Find

find * -type f -name "*.log" -exec grep -i 'error' {} \;

Unlocking Accounts on OEL

pam_tally2 --user oracle --reset

Killing multiple processes

ps -ef | grep -i searchterm | grep -v grep | awk '{print "kill -9 "$2}'