title: Bash: loop through variables containing pattern in name
body: <p>In my script I have an unknown number of variables containing angles which I want to convert to vectors. I made the variable-names such that the angles of each 'parameter' are of the form:
      {parameter}_angle_{lat/perp}
  Hence, each parameter has a 'lat' and 'perp' angle variable.
  So what I want to do is to find all variables containing '_angle_lat', do some calculations on the values of these variables and create a new variable which contains the 'parameter'-name in it.
  for example:</p>
  
  <pre><code>export M0_angle_lat=4
  export M1_angle_lat=70
  export M1_angle_perp=8
  export M0_angle_perp=90
  
  # Now I want to use these values to calculate vectors
  for varname in *_angle_lat
  do
      # at first iteration it will get for example "varname=M0_angle_lat" in which case
      # I want it to do:
      M0_X=$(( $M0_angle_lat * $M0_angle_perp ))
      # The second iteration in case would then give "varname=M1_angle_lat" in which case
      # I want it to do:
      M1_X=$(( $M1_angle_lat * $M1_angle_perp ))
  done
  </code></pre>
  
  <p>I hope it's clear what my goal is here. Thanks for the help!</p>