This piece of code transforms the variable as its printed to lowercase
print $ORACLE_SID|tr '[A-Z]' '[a-z]'
In order to get set -o vi
This should be set at the .kshrc or .bashrc level
# M Culp # .kshrc # Source global definitions if [ -f /etc/kshrc ]; then . /etc/kshrc fi # use emacs editing mode by default # set -o emacs set -o vi # User specific aliases and functions
For the bash folks here is the .bashrc file
# .bashrc # User specific aliases and functions alias rm='rm -i' alias cp='cp -i' alias mv='mv -i' # Source global definitions if [ -f /etc/bashrc ]; then . /etc/bashrc fi set -o vi
check_sys_pass() { ###################################################### # This will read a .file for the system password # or prompt for a password ###################################################### export PWFILE=.syspasswd if [ ! -f $PWFILE ]; then echo "Please enter the SYS password on the primary database: $PRIMARY_DB on $PRIMARY_HOST :"; read sys_pass else sys_pass=$(cat $PWFILE |head -1) fi }
-- ----------------------------------------------------------------------------------- -- File Name : https://oracle-base.com/dba/monitoring/longops.sql -- Author : Tim Hall -- Description : Displays information on all long operations. -- Requirements : Access to the V$ views. -- Call Syntax : @longops -- Last Modified: 03/07/2003 -- ----------------------------------------------------------------------------------- COLUMN sid FORMAT 999 COLUMN serial# FORMAT 9999999 COLUMN machine FORMAT A30 COLUMN progress_pct FORMAT 99999999.00 COLUMN elapsed FORMAT A10 COLUMN remaining FORMAT A10 SELECT s.sid , s.serial# , s.machine , ROUND(sl.elapsed_seconds/60) || ':' || MOD(sl.elapsed_seconds,60) elapsed , ROUND(sl.time_remaining/60) || ':' || MOD(sl.time_remaining,60) remaining , ROUND(sl.sofar/sl.totalwork*100, 2) progress_pct FROM v\$session s, v\$session_longops sl WHERE s.sid = sl.sid AND s.serial# = sl.serial#;
This should go into the Linux_common.ksh library file
cr_tar_apex_common() { # Create the tar file tar -cvf /oracle/admin/scripts/mrc/apex_common_09062017.tar /oracle/admin/scripts/apex/*.ksh /oracle/admin/scripts/dba120/apex6 }
tar --help
Examples:
# Create archive.tar from files foo and bar.
tar -cf archive.tar foo bar
# List all files in archive.tar verbosely.
tar -tvf archive.tar
# Extract all files from archive.tar
tar -xf archive.tar
On Linux using -cvf will
c = create a tar
v = verbosely list the files
f = use archive file
The tar command allows creating a .tar file that can be gziped for easier transmit and smaller size
To pull a file from the archive you can use this tar -xzf archive.tar.gz my/path/to/file.txt To list the files in the archive tar tzf archive.tar.gz
t = list
z = zipped
v = verbose (if you include this you will see the dates of the files)
f = file archive
tar does not support "in-place" updating of files. However, you can add files to the end of an archive, even if they have the same path as a file already in the archive. In that case, both copies of the file will be in the archive, and the file added later will override the earlier one. The command to use for this is tar r (or tar u to only add files that are newer than the archive) is the command to use. The . in the path should not be a problem.
There is a catch, though: you can't add to a compressed archive. So you would have to do:
Unzip the tar gunzip archive.tar.gz add to the tar file once it is unzipped tar rf archive.tar data/data/com.myapp.backup/./files/settings.txt rezip the tar file gzip archive.tar add to the mrc_10192017.tar file unzipped tar -rvf mrc_10192017.tar /oracle/admin/scripts/mrc/nc1xtxsb03
function db_switch { ############################################################################### # function switches the database environments for any databases on the cluster # ############################################################################### #cd /var/opt/oracle/admin/scripts #. ./env_generic # export NEW_ORACLE_SID=ASM1+; . ~/.profile > /dev/null echo echo "Check database(s) in OCR" echo --------------------------------------- echo gen_db_lst #srvctl config > dblst #echo #echo "Databases listed in clusterware" #cat dblst #echo export NEW_ORACLE_SID=FYTEST1; . ~/.profile > /dev/null sqlplus -s "/ as sysdba" < /dev/null sqlplus -s "/ as sysdba" < /dev/null sqlplus -s "/ as sysdba" < /dev/null dashboard # end of function }
This piece of code sets files equal to 3 different files, then goes through a for / next loop to determine if they exist
#!/bin/ksh files="/etc/passwd /etc/group /etc/hosts" for f in $files; do if [ ! -f $f ] then echo "$f file missing!" fi done
#!/bin/ksh for car in $(cat car.txt) do print "Current Car : $car" done
#!/bin/ksh for f in $(ls /tmp/*) do print "Full file path in /tmp dir : $f" done
look for large files with this command:
find . -type f -size +100000k -exec ls -lh {} \; | awk ‘{ print $9 “: ” $5 }’This looks for files over 100MB, but other than datafiles there were very few files found. I knew I needed to look for large directories. Directories that had a large amount of small files. This command worked nicely:
du -h / | grep ^[1-9][0-9][0-9.]*G | sort -rnFrom there I was able to find the directories that I needed to clear out.
Find and zip files newer than X minutes
find . -mmin -1620 -type f -name \*_lm[d,s]\*trc -print -exec zip /tmp/`hostname`_lm_files.zip {} \;