我有兩個變量命名爲A和B的主題文件和分數像下面在UNIX shell腳本的嵌套的循環
A=contents of file 'subject' which contains "English Hindi Telugu"
B=contents of file 'Scores' which contains "60 60 10"
我要標記在各自的方式標記的主題即
english ==> 60 hindi ==> 60 telugu ===>10
我實現如下,但其顯示怪異的結果:
English ==> 60 English ==> 60 English ==> 10 Hindi ==> 60
Hindi ==> 60 Hindi ==> 10 Telugu ==> 60 Telugu ==> 60 Telugu ==> 10
我希望結果是像下面趙運SH ==> 60印地文==> 60泰盧固語==> 10
#!/bin/ksh
A=`cat subject`
B=`cat Scores`
for sub in $A
do
for score in $B
do
echo " $sub ==> $score "
done
done
可能的複製(http://stackoverflow.com/questions/9885338/reading-從兩個文件在一個循環中的線) – tripleee
嵌套循環必須重複每個迭代的外循環內循環。這顯然不是你想要的;你應該澄清標題。 – tripleee