I have main set of values and a subset to it
Main Set: Group1,Group2,Group3
Subset : Group1_Sub1,Group1_Sub2,Group2_Sub1,Group3_Sub1,Group3_Sub2
Group1 ->Group1_Sub1 and Group1_Sub2
Group2 ->Group2_Sub1
Group3 ->Group3_Sub1,Group3_Sub2
For each main list, I would like to loop only through its corresponding sub group list and display output.
Currently I am using below code
for %%s in (
Group1,Group2,Group3
) do (
echo set Main Group %%s >> Log.txt
for %%i in (
Group1_Sub1,Group1_Sub2,Group2_Sub1,Group3_Sub1,Group3_Sub2
) do (
echo Main Group is %%s and its sub group is %%i >>Log.txt
)
)
Above code will give me the out put as :
set Main Group Group1
Main Grpup is Group1 and its sub group is Group1_Sub1
Main Grpup is Group1 and its sub group is Group1_Sub2
Main Grpup is Group1 and its sub group is Group2_Sub1
Main Grpup is Group1 and its sub group is Group3_Sub1
Main Grpup is Group1 and its sub group is Group3_Sub2
set Main Group Group2
Main Grpup is Group2 and its sub group is Group1_Sub1
Main Grpup is Group2 and its sub group is Group1_Sub2
Main Grpup is Group2 and its sub group is Group2_Sub1
Main Grpup is Group2 and its sub group is Group3_Sub1
Main Grpup is Group2 and its sub group is Group3_Sub2
set Main Group Group3
Main Grpup is Group3 and its sub group is Group1_Sub1
Main Grpup is Group3 and its sub group is Group1_Sub2
Main Grpup is Group3 and its sub group is Group2_Sub1
Main Grpup is Group3 and its sub group is Group3_Sub1
Main Grpup is Group3 and its sub group is Group3_Sub2
I would like to restrict them to go through only its corresponding list like below
set Main Group Group1
Main Grpup is Group1 and its sub group is Group1_Sub1
Main Grpup is Group1 and its sub group is Group1_Sub2
set Main Group Group2
Main Grpup is Group2 and its sub group is Group2_Sub1
set Main Group Group3
Main Grpup is Group3 and its sub group is Group3_Sub1
Main Grpup is Group3 and its sub group is Group3_Sub2
How can I achieve this ?
for /f, set will output all vars with a given prefix and their content.