U of A University of Arkansas Division of Agriculture

Pictures of chickens, flowers, wheat, a boy looking through a magnifying glass, irrigation pipe, soybean pods, and fruits and vegetables.

Cooperative Extension Service

Cooperative Extension Service

Agricultural Experiment Station

Steve Rea's
Oracle Tips, Tricks, and Scripts

Link to Steve Rea's Oracle Certification graphic


Search | Publications | Jobs | Personnel Directory | Links

UNIX Tips and Tricks

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 '^[^ ]'

This Page was Last Updated on 06/04/07

You Are Visitor Number

Hit Counter

Link to CES Home PageBack To CES Home Page

Link to Steve Rea's Oracle PageBack To Steve Rea's Oracle Page

Back to top of this pageBack To Top


© 2006
University of Arkansas
Division of Agriculture
All rights reserved.
Last Date Modified 02/09/2008
Webmaster

University of Arkansas • Division of Agriculture
Cooperative Extension Service
2301 South University Avenue
Little Rock, Arkansas 72204 • USA
Phone (501) 671-2000 • Fax (501) 671-2209
 

MissionDisclaimerEEO
PrivacyFOI