title: Bash script that detects the type of argument it's given
body: <p>I have a bash script that will take one argument: a product ID. The product ID can be in one of two formats: all numbers, or a mix of letters, numbers, and underscores. Depending on which type of ID is entered, the script will handle it in a slightly different way.</p>
  
  <p>Right now, I'm using <code>getopts</code> with one flag for each subtype to distinguish between which type of product ID I'm going to be using in the script. For example:</p>
  
  <p><code>./myscript -n 1034596</code></p>
  
  <p>or</p>
  
  <p><code>./myscript -v AB_ABCD_12345</code></p>
  
  <p>With a simplified version of the script looking like this:</p>
  
  <pre><code>#!/bin/bash
  while getopts ":n:v:" opt; do
    case $opt in
      n)
        echo "This is a numbers only ID." &gt;&amp;2
        ;;
      v)
        echo "This is a letters, numbers, underscore ID" &gt;&amp;2
        ;;
    esac
  done
  </code></pre>
  
  <p>Since the formats are static, that is, the first type of ID will never be anything but numbers, is there any way to automatically distinguish between the two types of IDs and handle them appropriately without the need for the <code>-n</code> or <code>-v</code> flag? So, I could just enter <code>./myscript 1034596</code> and the script will know that since the argument contains nothing but numbers it should process it a specific way.</p>