#取出文件名和路径到/oracle/filename_temp.txt文件中,这里把文件名和路路径用 | 分开了 方便awk取值
echo "sqlplus user/pwd@sid <<!!
set feedback off
set heading off
set pagesize 0
set linesize 50
set term off verify off
set echo off
set colsep ","
set trimspool on
spool /oracle/filename_temp.txt
select filepath||'|'||filename from temptable;
spool off
quit
!! " > /oracle/filename_temp.sh
sh /oracle/filename_temp.sh
rm /oracle/filename_temp.sh
cat /oracle/filename_temp.txt|grep -v SQL|while read line
do
filepath=`echo $line|awk -F '|' '{print $1}'`
filename=`echo $line|awk -F '|' '{print $2}'`
mkdir -p /oracle/$filepath #这里的路径可能还要根据你的要求自己改下
cd /oracle/$filepath
touch $filename
done
追问谢谢!已经实现,但是是分成两个shell脚本,两部分内容不知可否合为一个shell脚本?