为什么while和while或for的嵌套循环是错误的?



在我的项目中,我使用linux shell获取一些数据

当我运行脚本时,我发现了一个错误。

我写了一个test.sh来测试我的代码:
[john@node04 findApp]$ cat test.sh 
while read line
do
echo $line
while read Row
do
done < daysnameFiles
done < allUserAppIn

当我运行测试代码时,我得到语法错误

[john@node04 findApp]$ sh test.sh 
test.sh: line 6: syntax error near unexpected token `done'
test.sh: line 6: `   done < daysnameFiles'

我已经尝试了另一种使用方法:

while read line 
do
rslInfo=$line
for j in $(cat daysnameFiles)
do
echo "test"
done
done < allUserAppIn

我得到了相同的错误。

我认为你需要在内循环中做点什么。

while read line
do
echo $line
while read Row
do
echo "here"
done < daysnameFiles
done < allUserAppIn

最新更新