您好,我正在尝试运行循环并获取项目的详细信息。我的工作空间中有这些项目。如何循环执行 SQL 代码?
#!/bin/bash
workspace=$(sudo locate -r '/workspace$')
cd $workspace
echo "" > ~/Desktop/workspace.txt
for projectName in `ls -d *`;
do
echo $projectName >> ~/Desktop/workspace.txt
done
cat workspace.txt | while read Name
sqlplus $1/$2 <<ENDOFSQL > ~/Desktop/$Name.txt
DESC PROJECTS;
SELECT ID_NAME, VALUE FROM PROJECTS WHERE ID_NAME='%${Name}%';
exit;
ENDOFSQL
echo "Testing"
当我运行它时,我收到错误
./sql_parameters.sh: line 24: syntax error: unexpected end of file
答案1
两件事情:
而应该是这种形式
while condition; do
your code from while
done
另外,请确保 ENDOFSQL 来自新行并且之间没有空格。