Popular recipes tagged "grep" but not "parse"http://code.activestate.com/recipes/tags/grep-parse/2014-03-05T19:47:50-08:00ActiveState Code Recipesgrep in Python (Python)
2014-03-05T19:47:50-08:00Andy Dustmanhttp://code.activestate.com/recipes/users/2435929/http://code.activestate.com/recipes/578845-grep-in-python/
<p style="color: grey">
Python
recipe 578845
by <a href="/recipes/users/2435929/">Andy Dustman</a>
(<a href="/recipes/tags/generator/">generator</a>, <a href="/recipes/tags/grep/">grep</a>, <a href="/recipes/tags/search/">search</a>).
</p>
<p>The grep() function is inspired by UNIX grep, but is not limited to string patterns and files or streams.</p>
find + grep (Bash)
2013-09-17T08:48:07-07:00yotahttp://code.activestate.com/recipes/users/4184815/http://code.activestate.com/recipes/578661-find-grep/
<p style="color: grey">
Bash
recipe 578661
by <a href="/recipes/users/4184815/">yota</a>
(<a href="/recipes/tags/find/">find</a>, <a href="/recipes/tags/grep/">grep</a>, <a href="/recipes/tags/zsh/">zsh</a>).
Revision 2.
</p>
<p>look for a text pattern in files defined by a pattern.
First argument is passed to the find command, second one to the grep</p>
<p>./find_n_grep.sh '*.py' 'dict'</p>
<p>more over, it sort by date.</p>
Flatten XML to XPath syntax lines (Python)
2011-01-19T16:05:24-08:00Raphaël Jolivethttp://code.activestate.com/recipes/users/4135673/http://code.activestate.com/recipes/577547-flatten-xml-to-xpath-syntax-lines/
<p style="color: grey">
Python
recipe 577547
by <a href="/recipes/users/4135673/">Raphaël Jolivet</a>
(<a href="/recipes/tags/flatten/">flatten</a>, <a href="/recipes/tags/grep/">grep</a>, <a href="/recipes/tags/sed/">sed</a>, <a href="/recipes/tags/xml/">xml</a>, <a href="/recipes/tags/xpath/">xpath</a>).
</p>
<p>This script acts like <a href="http://www.ofb.net/~egnor/xml2/">xml2</a>.
It transforms a XML file into a flat text output, with <em>XPath</em>-like syntax, one line per XML node or attribute.
This format is more suitable for working with standard unix CLI utils (sed, grep, ... etc).</p>
Access grep from python (Python)
2010-02-24T08:30:25-08:00Daniel Cohnhttp://code.activestate.com/recipes/users/4172918/http://code.activestate.com/recipes/577069-access-grep-from-python/
<p style="color: grey">
Python
recipe 577069
by <a href="/recipes/users/4172918/">Daniel Cohn</a>
(<a href="/recipes/tags/files/">files</a>, <a href="/recipes/tags/grep/">grep</a>, <a href="/recipes/tags/linux/">linux</a>).
</p>
<p>The recipe below passes a filename and an argument to grep, returning the stdout and stderr. Each line in the stdout will have its line number prepended.</p>
uniform matcher( "re pattern" / re / func / dict / list / tuple / set ) (Python)
2009-05-06T06:17:16-07:00denishttp://code.activestate.com/recipes/users/4168005/http://code.activestate.com/recipes/576741-uniform-matcher-re-pattern-re-func-dict-list-tuple/
<p style="color: grey">
Python
recipe 576741
by <a href="/recipes/users/4168005/">denis</a>
(<a href="/recipes/tags/grep/">grep</a>, <a href="/recipes/tags/re/">re</a>, <a href="/recipes/tags/text_processing/">text_processing</a>, <a href="/recipes/tags/uniform/">uniform</a>).
Revision 2.
</p>
<p>matcher() makes a string matcher function from any of:</p>
<ul>
<li>"RE pattern string"</li>
<li>re.compile()</li>
<li>a function, i.e. callable</li>
<li>a dict / list / tuple / set / container</li>
</ul>
<p>This uniformity is simple, useful, a Good Thing.</p>
<p>A few example functions using matchers are here too: grep getfields kwgrep.</p>