| Steve Rea's Oracle and SunGardHE Banner Tips, Tricks, and Scripts Back to Home |
Here are some AIX Unix one-liners (or, n-liners) you might find interesting or something to build from.
Get total size of files in a directory (/home here; awk adds 5th column from "ls -l" command):
ls -l /home | awk '{total += $5}; END {print total}'
Get total size of files in a directory and it's subdirectories (/home here; recursive ls):
ls -lR /home | awk '{total += $5}; END {print total}'
Get total size above, but, excluding directory entries (grep drops "ls -l" lines beginning with d):
ls -lR /home | grep -v '^d' | awk '{total += $5}; END {print total}'
Find all files for an Oracle database SID (PROD here; "find" also excludes directory names and masks error messages; egrep passes only files with database suffixes; grep excludes temp sga file) following standard naming convention (the first two lines), and create the shell commands (sed parses pathnames into directory (\1) and file (\2) names to create commands) to zip those files (using gzip (GNU zip)) into a zip directory (PROD.gzip here) while preserving the timestamps (using touch; the third line is one long line from "sed" through "zipem.shl"; the database would have to be shut down before actually running the resulting zipem.shl script):
find / -name "*PROD*" ! -type d 2>/dummy |
egrep '(\.ora$|\.dbf$|\.ctl$|\.rdo$)' | grep -v sgadef |
sed "s/\(.*\/\)\([^\/].*\)/gzip -cv1 \1\2 >\/u05\/oradata\/PROD.gzip\/\2.gz;
touch -r \1\2 \/u05\/oradata\/PROD.gzip\/\2.gz/" >zipem.shl
Get list of Oracle products installed in the current $ORACLE_HOME:
/usr/bin/cat $ORACLE_HOME/unix.prd |\
/usr/bin/nawk -F\" '{ printf ("%-40s %-10s %-20s\n", $6, $2, $4) }' |\
/usr/bin/grep '^[^ ]'
or (gives a few less):
/usr/bin/cat $ORACLE_HOME/orainst/unix.rgs |\
/usr/bin/nawk -F\" '{ printf ("%-40s %-10s %-20s\n", $6, $2, $4) }' |\
/usr/bin/grep '^[^ ]'
You Are Visitor Number |
This Page Was Last Updated on 09/23/09 |
Copyright © 2009 by Maristream.
All information, scripts, forms, and other material
on this web site are freely available to all Banner and Oracle Database Administrators,
Systems Administrators, Programmers, and others that may need it.
The webmaster who maintains this web site may be reached at srea@maristream.org. Visit our other web sites:
|
Maristream - New Product Research and Development |
Disclaimer: As with all software, especially where it affects your vital data, make sure that you examine theses scripts and that you understand what they do before you use them to see if they would have any adverse effect on your particular setup or database layout. Make a full backup of your database in case you have to revert to your original copy of the database before the scripts were run. Use these scripts at your own risk. As a condition of using these scripts, you agree to hold harmless both Maristream and Stephen Rea for any problems that they may cause or other situations that may arise from their use, and that neither Maristream nor I will be held liable for those consequences.