title: getopts not working in bash script
body: <pre><code>#! bin/bash
  # code for train.sh
     while getopts "f:" flag
      do
           case $flag in 
               f)
                 echo "Hi" 
                 STARTPOINT = $OPTARG
                 ;;
           esac
      done
  
      echo Test range: $4
      echo Train range: $3
  
      #path of experiment folder and data folder:
      EXP_DIR="$1"
      DATA_DIR="$2"
      echo Experiment: $EXP_DIR
      echo DataSet: $DATA_DIR
      echo file: $STARTPOINT
  
  
  I ran the command &gt; ./train.sh test1  test2 test3 test4  -f testf  
  </code></pre>
  
  <p>and got the output</p>
  
  <pre><code>Test range: test4
  Train range: test3
  Experiment: test1
  DataSet: test2
  file:
  </code></pre>
  
  <p>So getopts option does not seem to work for some reason as you can see the nothing is printed after file and also echo "Hi" command is not executed in the case statement. Can anyone please help me with this?</p>