用于检查 oracle 表状态并将文件移动到适当目录的 UNIX shell 脚本

用于检查 oracle 表状态并将文件移动到适当目录的 UNIX shell 脚本

我需要循环遍历 UNIX 中的销售文件,然后检查 oracle 表中的文件状态(svc_posupld_status 表中的状态列)。如果状态为 C,则将文件移动到“完毕" 目录。如果文件状态不是 C ,则将文件移动到 "拒绝“目录我写了以下代码

for file in `find . -type f -name "POSU*.dat.*" |sort |awk 'gsub("^./","")' | egrep -v "/"`
do
  echo "select reference_id, status from svc_posupld_status where reference_id = '$file'  ;" >>outfile.sql
  echo exit | $ORACLE_HOME/bin/sqlplus -s $UP @outfile.sql >> sql.log
done
 - if the status is C then move the file to done directory
 - if the status is NOT C then move the file to reject directory

如何检查状态并相应地移动文件?

相关内容