This part is not implemented yet, but it will come soon.
Or you can look at my Linux Site
#!/bin/ksh # while [ 1 ]; do date; ./dbspace_alert.sh; sleep 30; done MY_COUNT=`sqlplus -s / as sysdba<<EOF set pagesize 0 feedback off echo off term off verify off newpage 0 head off ttitle off select count(*) cnt from dba_resumable; -- test select count(*) cnt from dba_tables; EOF ` echo $MY_COUNT|sed 's/ //g' if [[ $MY_COUNT -eq 0 ]]; then echo "ok" else echo "not ok" echo "mydb has space issue"|mailx -r aaa.bbb.vipalert@ccc.com -s "mydb on myhost has space issue" aaa.bbb@ccc.com fi
# examples of while
=================
#!/bin/ksh
-- ---------------------------
i="1"
while [ $i -gt 0 ]
do
sqlplus <<-EOF
myusername@$ORACLE_SID/$PASSWORD
@@my_prog.sql
EOF
DATE=`date | cut -c 1-19`
echo "Process Completed at " $DATE
read
i=`grep "ORA-01555" my_prog.prt |wc -l`
done
-- -------------------------
# ********* commented_for_accidental_run ************
## remove all empty directories, commented out for accidental run
##!/bin/ksh
#cnt=`find . -type d -print | nawk -F"/" 'BEGIN{ level = 0 } { if (NF > level) {level = NF} } END{ print level }' \
#` while [ $cnt -gt 0 ] do \
# for dirname in `find . -type d ` \
# do
# file_cnt=`ls -1 $dirname | wc -l`
# if [ $file_cnt = 0 ]
# then
# echo " $dirname is empty ";
# rmdir $dirname
# fi;
# done
# cnt=$(($cnt-1))
#done
# ************
# remove directory under some pattern
#commented_for_accidental_run find /../mydir -mtime +130 -name "filename.mysuffix" -exec /bin/rm -f {} \;
or
#commented_for_accidental_run find . -name "*.aud" -mtime +170 -exec rm {} \;
************
For making the replacement in all files in the current directory
#commented_for_accidental_run perl -p -i -e "s/PATTERNA/PATTERNB/g" *
And then to search and make changes in files in the current and all sub directories:
#commented_for_accidental_run find . -type f -print | xargs perl -p -i -e "s/PATTERNA/PATTERNB/g"
# -- -------------------------
=====================================================
Function
sum(){
s=`expr $1 + $2`
return $s
}
sum $1 $2 || total=$?
echo $total
=====================================================
# Rename file without its extension
#There are lots of ways to accomplish this ... one of them is:
for fname in `ls *.log`
do
fname=${fname%\.log}
echo $fname
done
=====================================================
Using bc I can do this;
# bc
scale=4
50 / 100
.5000
quit
But, how to get this value, .5 in a script? When I script this, the script returns a 0, not a .05.
I'm using ksh at the moment.
VarName=$(bc < filea
V=`bc -l filea <