|

楼主 |
发表于 2008-12-16 12:52:10
|
显示全部楼层
我昨天想了一个稍微复杂的办法:
declare -a paris
j=-1
for STA1 in aa bb cc dd ee
do
for STA2 in aa bb cc dd ee
do
j=$[j+1]
paris[j]=$STA1$STA2
echo paris=${paris[j]}
echo parisall=${paris[@]}
donext="YES"
if test $STA1 != $STA2
then
i=-1
while test $i -lt $j
do
i=$[i+1]
if test $STA2$STA1 = ${paris}
then
echo test2= $STA2$STA1
donext="NO"
fi
done
fi
echo donext= $donext
done
done
你这个方法比较简单,也适合我的问题。非常感谢,学习了
不过就你给的那个例子来说,eeaa或者aaee是没有做的。
就是说,在两个list中,只有他们完全相同时(也正是我的问题),
才能正确实现。如果不同的话,就丢了一些对,比如eeaa
Post by haimming803;1924216
i=0
for str1 in aa bb cc dd ee
do
echo $i
j=0
for str2 in aa bb cc dd ff
do
if [[ "$i" -le "$j" ]]
then
your jobs
fi
((j++))
done
((i++))
done |
|