title: How to use ${OPTARG} on getopts?
body: <p>I have the following code:</p>
  
  <pre><code>while getopts ":p:t:n:" o; do
  case "${o}" in
      p)
          p=${OPTARG}
          numep=$p
          mkdir $numep
          ;;
      t)
          t=${OPTARG}
          tip=$t
          if [ $tip == "c" ]; then
              touch $numep/$numep.c
              touch $numep/$numep.h
          elif [ $tip == "c++" ]; then
              touch $numep/$numep.cpp
              touch $numep/$numep.h
          fi
              ;;
          n)
              n=${OPTARG}
              nrFis=$n
              if [ $tip == "c" ]; then
                  for i in $(seq $n); do
                      touch $numep/src/$numep$i.c
                      touch $numep/inc/$numep$i.h
                  done
              elif [ $tip == "c++" ]; then
                  for i in $(seq $n); do
                      touch $numep/src/$numep$i.cpp
                      touch $numep/inc/$numep$i.h
                  done
              fi
              ;;
          *)
              err-help
              ;;
          esac
      done
  </code></pre>
  
  <p>err-help is a previously defined function that delivers instructions for a correct call.</p>
  
  <p>A correct call of the script looks like this: <code>./script.sh -p project_name -t project_type -n source_files_number</code></p>
  
  <p>What am I trying to do: create a directory with a specific number of source files for a c or a c++ project.</p>
  
  <p>My questions here: How do I have to use the ${OPTARG} ? What exactly does the p=${OPTARG} thing? Will the p, t, n variables fill with the right content?
  How am I doing this right, please? :(</p>