0

I need to while loop a couple of input fields, then get the values of these inputs to filter some logs. The value was able to store in $input1 in this case, but how do I code it dynamically for input$i, input$i, input$i (where i=1 i=2 i=3…)?

i=1
filter=case1_inputs_filter${i}
echo ${filter}_field
echo ${filter}_required
echo ${filter}_length


a=${filter}_field 
echo ${!a}

b=${filter}_required 
echo ${!b}

c=${filter}_length 
echo ${!c}


while [ -n "${!a}" ]
do
    echo -e "\nEnter ${!a} (required): "
    read input${i}
    echo $input1 # Works! 

    # How to reuse $input1 to be dynamic?
    echo ${!input$i} # Not work!
    echo ${input}{$i}} # Not work!
    echo ${input}{$i} # Not work!
    echo $input{$i} # Not work! 

YAML config file

case1:
  inputs:
    filter1:
      field: username
      required: true
      length: 5
    filter2: date
      required: false
      length:
    filter3: time
      required: false
      length:

ccc

busterSg
  • 27
  • 5

0 Answers0