 <p>maybe I didn't understand OP's question well, why a simple grep command cannot do the job?</p> <p>like</p> <pre><code>grep -Po 'OPR\d+' </code></pre> <p>output for both lines are same:</p> <pre><code>OPR20120126120537008893 </code></pre>