title: Index of nth occurrence of a character in a given string in UNIX
body: <p>consider the string</p>
  
  <pre><code>s=pqrPQR456PQRpqr
  </code></pre>
  
  <p>Now</p>
  
  <pre><code>expr index $s p
  </code></pre>
  
  <p>gives me ans as 1</p>
  
  <p>But how to find index of p which is after R or index of any repetitive character; that is what I'm  unable to get.</p>