title: Regular Expression in Java Vs regular expression in Shell Script
body: <p>My task was to write a regular expression in java and shell script which will validate all strings contaning only a single digit and any number of characters preceded or followed by that digit.</p>
  
  <p>I wrote <code>[a-z]*[0-9]{1}[a-z]*</code> and it worked fine for <strong>Java</strong> but it is not at all working for <strong>Shell Script</strong>
  Can anyone please help me to create a regular esxpression meeting my requirement in <strong>Shell Script</strong></p>
  
  <p><strong>Edit</strong> <em>(from comments)</em>:
  I tried with <code>grep</code> but it did not gave me useful results. [...] If the string validates I want to perform certain operations. So I used it like </p>
  
  <pre><code>if [$password eq [a-z]*[0-9]{1}[a-z]]; then 
      # "do this" 
  else 
      # "do that" 
  fi 
  </code></pre>
  
  <p>Could you put some light on syntax differences in Java and shell script related to regular expressions?</p>