 <p>Here's one way using <code>awk</code>:</p> <pre><code>awk -F "[{}]" '{ for(i=1;i&lt;=NF;i++) if ($i == "ctr") print $(i+1) }' file </code></pre> <p>Or if your version of <code>grep</code> supports Perl-like regex:</p> <pre><code>grep -oP "(?&lt;=ctr{)[^}]+" file </code></pre> <p>Results:</p> <pre><code>StaffLine </code></pre>