title: Bash command line arguments, replacing defaults for variables
body: <p>I have a script which has several input files, generally these are defaults stored in a standard place and called by the script.</p>
  
  <p>However, sometimes it is necessary to run it with changed inputs.</p>
  
  <p>In the script I currently have, say, three variables, $A $B, and $C. Now I want to run it with a non default $B, and tomorrow I may want to run it with a non default $A and $B.</p>
  
  <p>I have had a look around at how to parse command line arguments:</p>
  
  <p><em><a href="https://stackoverflow.com/questions/192249/how-do-i-parse-command-line-arguments-in-bash">How do I parse command line arguments in Bash?</a></em></p>
  
  <p>How do I deal with having some set by command line arguments some of the time?</p>
  
  <p>I don't have enough reputation points to answer my own question. However, I have a solution:</p>
  
  <p><em><a href="https://stackoverflow.com/questions/4609668/override-a-variable-in-a-bash-script-from-the-command-line/4610469#4610469">Override a variable in a Bash script from the command line</a></em></p>
  
  <pre><code>#!/bin/bash
  a=input1
  b=input2
  c=input3
  while getopts  "a:b:c:" flag
  do
      case $flag in
          a) a=$OPTARG;;
          b) b=$OPTARG;;
          c) c=$OPTARG;;
      esac
  done
  </code></pre>