歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
您现在的位置: Linux教程網 >> UnixLinux >  >> Linux基礎 >> 關於Linux

linux文件入庫腳本

linux文件入庫腳本   ----linux文件入庫腳本  #!/bin/bash  #一個輸入參數時間,格式為yyyymmdd,不輸入時,使用系統前一天日    if [ ${#1} -eq 6 ] ; then  day=$1  else  day=$(date -d "" +%Y%m)  fi    if [ ${#1} -eq 6 ] ; then  day1=$2  else  day1=$(date -d "1 month ago" +%Y%m)  fi  source /home/oracle/.bash_profile    file_name=/oradata/org_data/ftp_down/itv/login/itv_login.ctl    echo "LOAD DATA">$file_name  ls /oradata/org_data/ftp_down/itv/login/ |grep "$day" | while read -a line  do  echo "INFILE  \"/oradata/org_data/ftp_down/itv/login/${line[0]}\" \"str'\\r\\n'\"">>$file_name  done  echo "INTO TABLE ITV_LOGIN_M">>$file_name  echo "APPEND">>$file_name  echo "FIELDS TERMINATED BY '|'">>$file_name  echo "TRAILING NULLCOLS ">>$file_name  echo "( ">>$file_name  echo "WIDTHID,">>$file_name  echo "USERID,">>$file_name  echo "CREATEDATE,">>$file_name  echo "LOGINTIMES,">>$file_name  echo "VIEWMINUTS,">>$file_name  echo "LEIXING,">>$file_name  echo "MONTH CONSTANT "$day1"">>$file_name  echo ")">>$file_name    sqlldr  userid=username/passwd control=$file_name log=/oradata/org_data/ftp_down/itv/login/log/itvlogin_$day.log errors=600000000 direct=Y  
Copyright © Linux教程網 All Rights Reserved