1.通过循环得到可能出现的数值交叉情况,可能一个数值,可能两个数值,可能三个数值
var_mem_id_2=(100
200
300
400
500
600)
for line_01 in ${var_mem_id_2[@]}
do
echo $line_01 >> file.txt
for line_02 in ${var_mem_id_2[@]}
do
arry_02=($line_01,$line_02)
echo $arry_02 >> file.txt
for line_03 in ${var_mem_id_2[@]}
do
arry_03=($line_01,$line_02,$line_03)
echo $arry_03 >> file.txt
for line_04 in ${var_mem_id_2[@]}
do
arry_04=($line_01,$line_02,$line_03,$line_04)
echo $arry_04 >> file.txt
for line_05 in ${var_mem_id_2[@]}
do
arry_05=($line_01,$line_02,$line_03,$line_04,$line_05)
echo $arry_05 >> file.txt
for line_06 in ${var_mem_id_2[@]}
do
arry_06=($line_01,$line_02,$line_03,$line_04,$line_05,$line_06)
echo $arry_06 >> file.txt
done
done
done
done
done
done
2.对于得到的交叉的情况,剔除同一行的重复数据并排序
for line_01 in $(cat file.txt)
do
arry_01=`echo $line_01 | sed 's/,/
/g' | sort | uniq | tr -s '
' ',' | sed 's/,$//g'`
echo $arry_01 >> sort.csv
done
3.剔除整个文件的重复数据
sort -k2n sort.csv | uniq > a.csv