linux 文件入库脚本
----linux文件入库脚本
#!/bin/bash
#一个输入参数时间,格式为yyyymmdd,不输入时,使用系统前一天日
if[${#1}-eq6];then
day=$1
else
day=$(date-d""+%Y%m)
fi
if[${#1}-eq6];then
day1=$2
else
day1=$(date-d"1monthago"+%Y%m)
fi
source/home/oracle/.bash_profile
file_name=/oradata/org_data/ftp_down/itv/login/itv_login.ctl
echo"LOADDATA">$file_name
ls/oradata/org_data/ftp_down/itv/login/|grep"$day"|whileread-aline
do
echo"INFILE\"/oradata/org_data/ftp_down/itv/login/${line[0]}\"\"str'\\r\\n'\"">>$file_name
done
echo"INTOTABLEITV_LOGIN_M">>$file_name
echo"APPEND">>$file_name
echo"FIELDSTERMINATEDBY'|'">>$file_name
echo"TRAILINGNULLCOLS">>$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"MONTHCONSTANT"$day1"">>$file_name
echo")">>$file_name
sqlldruserid=username/passwdcontrol=$file_namelog=/oradata/org_data/ftp_down/itv/login/log/itvlogin_$day.logerrors=600000000direct=Y