在编辑脚本后,我不久想解释一下我想做什么:
这是我的脚本,有人可以告诉我这是否有效吗?我不确定语法,也不确定nr。 3和4。发送邮件是这样的。
#!/bin/sh
#check if files are in folder
declare -a arrCSV #create array
for file in *.csv
do
arrCSV=("${CSV[@]}" "$file")
done
shopt -s nullglob
for file in read*.csv; do
#run on all files starting with "read" and ending with ".csv"
for find $LOCATION -name $file -type f -mmin -60 do
if
sqlldr read*.csv
then mv "$file" "$HOME/fail/" ;
else{ echo "Failed to load" | mail -s "FAIL" email@email.com}
done
done
for file in write*.csv; do
#run on all files starting with "write" and ending with ".csv"
for find $LOCATION -name $file -type f -mmin -60 do
if
sqlldr write*.csv
then mv "$filen" "$HOME/unisem/fail/" ;
else { echo "Failed to load 2" | mail -s "FAIL" email@email.com}
done
done
答案 0 :(得分:1)
如果可以以任何顺序处理读写文件,则不需要数组:
shopt -s nullglob
for file in read*.csv; do
# run on all files starting with "read" and ending with ".csv"
sqldr ...
done
for file in write*.csv; do
# run on all files starting with "write" and ending with ".csv"
sqldr ...
done