标签:dbf 阻塞 ksh shel variables variable -- port utf8
---- shell 1
testdb3:/home/oracle [pprod] >more /home/oracle/utility/macro/tns_log_back_12c.sh
#! /usr/bin/ksh
#set -x
if [ $# = 0 ]
then
echo ""
echo "# usage: $0 tns log file name"
echo ""
else
# Set up the search paths:
PATH=$PATH:.
case $PATH in
*/usr/local/bin* ) ;;
*: ) PATH=${PATH}/usr/local/bin ;;
* ) PATH=${PATH}:/usr/local/bin ;;
esac
export PATH
# Set up the oracle variables:
export ORACLE_SID=pprod
export ORACLE_BASE=/opt/oracle12c
export ORACLE_HOME=/opt/oracle12c/product/12.1
export ORAENV_ASK=NO
. oraenv
export PATH=$ORACLE_HOME/bin:.:$PATH:/usr/bin:/usr/sbin:/etc
export LD_LIBRARY_PATH=/usr/lib:$ORACLE_HOME/lib
export PS1=`hostname`:‘${PWD} [$ORACLE_SID] >‘
export TERM=vt220
#export ORA_NLS33=$ORACLE_HOME/ocommon/nls/admin/data
export NLS_LANG=AMERICAN_AMERICA.ZHS16GBK
#export NLS_LANG=AMERICAN_AMERICA.UTF8
#export NLS_DATE_FORMAT=‘Mon DD YYYY HH24:MI:SS‘
umask 022
DATE=`date +%Y%m%d%H%M`
TNS_LOGNAME=$1
TNS_LOGBAK=`hostname`_${TNS_LOGNAME}_`date ‘+%Y%m%d%H%M‘`
TNS_LOGPATH=${ORACLE_HOME}/network/log
cd ${TNS_LOGPATH}
cp ${TNS_LOGNAME} ${TNS_LOGBAK}
if [ $? -ne 0 ]
then
echo "${bold}ERROR:Back tns log error!${normal}"
echo ""
exit 0
fi
> ${TNS_LOGNAME}
/usr/contrib/bin/gzip ${TNS_LOGBAK}
ls -lrt ${ORACLE_HOME}/network/log
fi
--shell 2
testdb3:/home/oracle [pprod] >more /home/oracle/utility/macro/compress_all.sh
SCRIPT_DIR=/home/oracle/utility/macro
PRG_NAME=$SCRIPT_DIR/compress_arch.sh
#$SCRIPT_DIR/compress_arch_ngen.sh nGenpr /ngprdblog 100 10
#$PRG_NAME nGende /ngdedblog 10
#$PRG_NAME nGenRO /ngrodblog 10
#$PRG_NAME nGenROA /ngroadblog 10
$PRG_NAME topspr /topsprdblog 10
$PRG_NAME gdpr /gdprdblog 10
#$PRG_NAME nGenpr /ngenprdblog 10
$PRG_NAME xprprod /xprproddblog 10
$PRG_NAME pcc /pccdblog 10
$PRG_NAME corpprod /corpproddblog 10
$PRG_NAME bpsprod /bpsproddblog 10
$PRG_NAME tgpsprod /tgpsproddblog 10
$PRG_NAME wrlprod /wrlproddblog 24
$PRG_NAME icomprod /icomproddblog 24
$PRG_NAME bizprod /bizlinkdblog 10
#add in 20160901
$PRG_NAME oasprod /oasprodlog 10
|
more compress_arch.sh
ORACLE_SID=$1
dname=$2
COMPRESS=/usr/contrib/bin/gzip
SCRIPT_DIR=/home/oracle/utility/macro
SLEEP="/usr/bin/sleep $3"
# 1. check whether db is up and running on server
up_flag=`${SCRIPT_DIR}/chkdbup.sh ${ORACLE_SID}`
if [ ${up_flag} -eq 0 ]; then
ls -t ${dname}/*.arc | awk -v SLEEP="${SLEEP}" -v COMPRESS=${COMPRESS} ‘
NR > 40 { print COMPRESS, $0;system(SLEEP) }
‘ | ksh -x
@@@解析 shell2
1. awk [-参数 变量] ‘BEGIN{初始化}条件类型1{动作1}条件类型2{动作2}。。。。END{后处理}‘
其中:BEGIN和END中的语句分别在开始读取文件(in_file)之前和读取完文件之后发挥作用,可以理解为初始化和扫尾。
(1)参数说明:
-F re:允许awk更改其字段分隔符
-v var=$v 把v值赋值给var,如果有多个变量要赋值,那么就写多个-v,每个变量赋值对应一个-v
e.g. 要打印文件a的第num行到num+num1行之间的行,
awk -v num=$num -v num1=$num1 ‘NR==num,NR==num+num1{print}‘ a
-f progfile:允许awk调用并执行progfile程序文件,当然progfile必须是一个符合awk语法的程序文件。
2.管道的作用
以下2条命令的输出可以比较 ,说明管道是一条条记录处理的。
ls -t /pproddblog/*.dbf*|more
ls -t /pproddblog/*.dbf*
3.NR 用法
NR NR 是总共读取了多少行
条件表达式使用两个符号--问号和冒号给表达式赋值: conditional expression1 ? expression2 : expressional3,其逻辑等同于C语言中的条件表达式。其对应的if/else语句如下:
{
if (expression1)
expression2
else
expression3
}
/> cat testfile
northwest NW Charles Main 3.0 .98 3 34
western WE Sharon Gray 5.3 .97 5 23
southwest SW Lewis Dalsass 2.7 .8 2 18
southern SO Suan Chin 5.1 .95 4 15
southeast SE Patricia Hemenway 4.0 .7 4 17
eastern EA TB Savage 4.4 .84 5 20
northeast NE AM Main Jr. 5.1 .94 3 13
north NO Margot Weber 4.5 .89 5 9
pal CT Ann Stephens 5.7 .94 5 13
/> awk ‘NR <= 3 {print ($7 > 4 ? "high "$7 : "low "$7) }‘ testfile
low 3
high 5
low 2
4.
先来看一下system()函数的简单介绍:
#include
int system(const char *command)
system()函数调用/bin/sh来执行参数指定的命令,/bin/sh 一般是一个软连接,指向某个具体的shell,比如bash,-c选项是告诉shell从字符串command中读取命令; 在该command执行期间,SIGCHLD是被阻塞的,好比在说:hi,内核,这会不要给我送SIGCHLD信号,等我忙完再说; 在该command执行期间,SIGINT和SIGQUIT是被忽略的,意思是进程收到这两个信号后没有任何动作。
标签:dbf 阻塞 ksh shel variables variable -- port utf8
原文地址:http://www.cnblogs.com/feiyun8616/p/6605775.html