title: Match exact word in bash script, extract number from string
body: <p>I'm trying to create a very simple bash script that will open new link base on the input command</p>
  
  <p><strong>Use case #1</strong></p>
  
  <pre><code>$ ./myscript longname55445
  </code></pre>
  
  <p>It should take the number <strong>55445</strong> and then assign that to a variable which will later be use to open new link based on the given number.</p>
  
  <p><strong>Use case #2</strong></p>
  
  <pre><code>$ ./myscript l55445
  </code></pre>
  
  <p>It should do the exact same thing as above by taking the number and then open the same link.</p>
  
  <p><strong>Use case #3</strong></p>
  
  <pre><code>$ ./myscript 55445
  </code></pre>
  
  <p>If no prefix given then we just simply open that same link as a fallback.</p>
  
  <p>So far this is what I have</p>
  
  <pre><code>#!/bin/sh
  
  BASE_URL=http://api.domain.com
  input=$1
  command=${input:0:1}
  
  if [ "$command" == "longname" ]; then
    number=${input:1:${#input}}
    url="$BASE_URL?id="$number
    open $url
  elseif [ "$command" == "l" ]; then
     number=${input:1:${#input}}
    url="$BASE_URL?id="$number
    open $url
  else
    number=${input:1:${#input}}
    url="$BASE_URL?id="$number
    open $url
  fi
  </code></pre>
  
  <p>But this will always fallback to the <code>elseif</code> there.</p>
  
  <p>I'm using <code>zsh</code> at the moment.</p>