A=Book,Pen,Pencil...n
B=Cat,Rat,Bat.....m
コードは次のとおりです。
Type=()
TEST=`echo $path`
echo $TEST
出力::
n/m
例外出力::
Book/Cat/Book/Rat/Book/Bat/..../Book/m/Pen/Cat/Pen/Rat/Pen/Bat/...../Pen/m/Pencil/Cat/Pencil/Rat/Pencil/Bat/..../Pencil/m/......./n/Cat/n/Rat/n/Bat/...../n/m
答え1
質問の要件を変更した後再び...
あなたはbash
使用することができます支柱の拡張:
$ printf '%s' {Book/,Pen/,Pencil/,n/}{Cat/,Rat/,Bat/,m/}
Book/Cat/Book/Rat/Book/Bat/Book/m/Pen/Cat/Pen/Rat/Pen/Bat/Pen/m/Pencil/Cat/Pencil/Rat/Pencil/Bat/Pencil/m/n/Cat/n/Rat/n/Bat/n/m/
出力は改行文字で終わりません。
とpath
2 つのカンマ区切り文字列を生成するには、次の手順を実行します。$A
$B
#!/bin/bash
A="Book,Pen,Pencil,n"
B="Cat,Rat,Bat,m"
oldIFS=$IFS
IFS=,
for i in $A; do
for j in $B; do
path+="$i/$j/"
done
done
IFS=$oldIFS
printf '%s\n' "$path"
出力:
$ ./script.sh
Book/Cat/Book/Rat/Book/Bat/Book/m/Pen/Cat/Pen/Rat/Pen/Bat/Pen/m/Pencil/Cat/Pencil/Rat/Pencil/Bat/Pencil/m/n/Cat/n/Rat/n/Bat/n/m/
答え2
この試み、
#complete_robotpath=() ### not used in script ... so commented
IFS=','
A=Basic-Call,Call-Hold ## In shell, we dont prefix with $ while declaring variable and should not have space in value.
B=VoLTE-VoLTE,VoLTE-3G
read -ra ADDR1 <<< "$A" ## In shell, we should pass value of a variable by prefixing with $
read -ra ADDR2 <<< "$B" IFS=',' ## In shell, we should pass value of a variable by prefixing with $
for i in "${ADDR1[@]}";
do
for j in "${ADDR2[@]}";
do
robot_path+=`echo $i/$j/` ## "+=" to concatinate string and sufix by / as expected result
done
done
pybot_exec_cmd=`echo $robot_path`
echo $pybot_exec_cmd
出力:
Basic-Call/VoLTE-VoLTE/Basic-Call/VoLTE-3G/Call-Hold/VoLTE-VoLTE/Call-Hold/VoLTE-3G/