sed "s/^/test/" 在每行開頭都添加test
grep '^[0-9]' $FileName 查找FileName這個文件的開頭是數字的每一行
sed "5s/ //g;5s/,//g" 去除第5行中的空格和","符號
ps -erf 显示所有进程,和grep配合使用更加飘逸
AIX下变量加减
n=0 n=0
n=$n+1 n=1
n=`printf %04d $n` 格式化数字,四位数字不足补零 n=0001
n=$($n+1) 相当于字符型要加1需要转换一下 n=2
ctrl+v+m=window的回车符
^=每行首
$=每行尾
nohup 关闭用户运行
& 后台运行
> 与 mv的区别,是没有写权限的mv可以移动,>需要写权限
linux red hat 和 AIX的一些区别:
aix red hat
n=$n+1; = ((n++));
zcat $FILE |tar -xvf - $6 = tar -Zxvf $FILE $6
######################DivideFile.sh######################
#!/usr/bin/ksh
FullFileName=$1
rownum=$2
nextId=$3
username=$4
password=$5
rmtPath=$6
recvPath=$7
n=0;
filePath=`echo $FullFileName|cut -d - -f 1`;
fileDate=`echo $FullFileName|cut -d / -f 6|cut -d - -f 3`;
count=$nextId;
fileName=$filePath"-SB-"$fileDate"-"$count".req";
sed '/BEGIN/d;/END/d' $FullFileName>tmp.dat;
echo "BEGIN">>$fileName;
while read line;
do
if (($n>=$rownum)); then
echo "END">>$fileName;
fileNo=`echo $fileName|cut -d . -f 1|cut -d - -f 4`;
fileNo=`printf '%04d' $(($fileNo+1))`;
rmtFile=`echo $fileName|cut -d . -f 1|cut -d / -f 7`;
rmtFullFileName=$rmtPath$rmtFile;
revcFullFileName=$recvPath"/fromhost/"$fileDate"/"$rmtFile".resp";
GenMD5Flg.sh $fileName;
sqlplus -s $username/$password<<EOF
set feedback off;
set pagesize 0;
insert into file_ftp_result (INT_TXN_DT, TXN_BRH_ID, FILE_DIRECTION_CD, FILE_TYPE_CD, FILE_TYPE_DTL_CD, FILE_NO, CLEAR_DT, LOC_FILE_NAME, RMT_FILE_NAME, TRANS_RSLT_CD, PROCESS_RSLT_CD, TRANS_FAIL_QT, MISC_TX, LAST_UPD_OPR_ID, GLOBAL_TXN_ID, LAST_UPD_TS)
values ('$fileDate', '03099997', '0', '10', '1002', '$fileNo', '$fileDate', '$fileName', '$rmtFullFileName.req', '0', '2', 0, ' ', 'ZB432', 'ZB432', sysdate);
insert into file_ftp_result (INT_TXN_DT, TXN_BRH_ID, FILE_DIRECTION_CD, FILE_TYPE_CD, FILE_TYPE_DTL_CD, FILE_NO, CLEAR_DT, LOC_FILE_NAME, RMT_FILE_NAME, TRANS_RSLT_CD, PROCESS_RSLT_CD, TRANS_FAIL_QT, MISC_TX, LAST_UPD_OPR_ID, GLOBAL_TXN_ID, LAST_UPD_TS)
values ('$fileDate', '03099997', '0', '10', '1004', '$fileNo', '$fileDate', '$fileName.flg', '$rmtFullFileName.req.flg', '0', '2', 0, ' ', 'ZB432', 'ZB432', sysdate);
insert into file_ftp_result (INT_TXN_DT, TXN_BRH_ID, FILE_DIRECTION_CD, FILE_TYPE_CD, FILE_TYPE_DTL_CD, FILE_NO, CLEAR_DT, LOC_FILE_NAME, RMT_FILE_NAME, TRANS_RSLT_CD, PROCESS_RSLT_CD, TRANS_FAIL_QT, MISC_TX, LAST_UPD_OPR_ID, GLOBAL_TXN_ID, LAST_UPD_TS)
values ('$fileDate', '03099997', '1', '10', '1003', '$fileNo', '$fileDate', '$revcFullFileName', '$rmtFullFileName.resp', '0', '0', 0, '$rmtFullFileName.req', 'ZB432', 'ZB432',sysdate);
exit;
EOF
((count++));
count=`printf '%04d' $count`;
fileName=$filePath"-SB-"$fileDate"-"$count".req";
echo "BEGIN">>$fileName;
n=0;
fi
echo "$line">>$fileName;
((n++));
done<tmp.dat
echo "END">>$fileName;
fileNo=`echo $fileName|cut -d . -f 1|cut -d - -f 4`;
fileNo=`printf '%04d' $(($fileNo+1))`;
rmtFile=`echo $fileName|cut -d . -f 1|cut -d / -f 7`;
rmtFullFileName=$rmtPath$rmtFile;
revcFullFileName=$recvPath"/fromhost/"$fileDate"/"$rmtFile".resp";
GenMD5Flg.sh $fileName;
sqlplus -s $username/$password<<EOF
set feedback off;
set pagesize 0;
update next_id t set t.next_id='$fileNo' where t.id_cd='CF' and t.sub_key_cd='Y';
insert into file_ftp_result (INT_TXN_DT, TXN_BRH_ID, FILE_DIRECTION_CD, FILE_TYPE_CD, FILE_TYPE_DTL_CD, FILE_NO, CLEAR_DT, LOC_FILE_NAME, RMT_FILE_NAME, TRANS_RSLT_CD, PROCESS_RSLT_CD, TRANS_FAIL_QT, MISC_TX, LAST_UPD_OPR_ID, GLOBAL_TXN_ID, LAST_UPD_TS)
values ('$fileDate', '03099997', '0', '10', '1002', '$fileNo', '$fileDate', '$fileName', '$rmtFullFileName.req', '0', '2', 0, ' ', 'ZB432', 'ZB432', sysdate);
insert into file_ftp_result (INT_TXN_DT, TXN_BRH_ID, FILE_DIRECTION_CD, FILE_TYPE_CD, FILE_TYPE_DTL_CD, FILE_NO, CLEAR_DT, LOC_FILE_NAME, RMT_FILE_NAME, TRANS_RSLT_CD, PROCESS_RSLT_CD, TRANS_FAIL_QT, MISC_TX, LAST_UPD_OPR_ID, GLOBAL_TXN_ID, LAST_UPD_TS)
values ('$fileDate', '03099997', '0', '10', '1004', '$fileNo', '$fileDate', '$fileName.flg', '$rmtFullFileName.req.flg', '0', '2', 0, ' ', 'ZB432', 'ZB432', sysdate);
insert into file_ftp_result (INT_TXN_DT, TXN_BRH_ID, FILE_DIRECTION_CD, FILE_TYPE_CD, FILE_TYPE_DTL_CD, FILE_NO, CLEAR_DT, LOC_FILE_NAME, RMT_FILE_NAME, TRANS_RSLT_CD, PROCESS_RSLT_CD, TRANS_FAIL_QT, MISC_TX, LAST_UPD_OPR_ID, GLOBAL_TXN_ID, LAST_UPD_TS)
values ('$fileDate', '03099997', '1', '10', '1003', '$fileNo', '$fileDate', '$revcFullFileName', '$rmtFullFileName.resp', '0', '0', 0, '$rmtFullFileName.req', 'ZB432', 'ZB432',sysdate);
exit;
EOF
if [ -s tmp.dat ];then
rm -f tmp.dat
fi