Using grep to compare two lists of Python packages
<p>I want to generate the list of packages install in Python 3, the list of all packages in Python 2.7 and find all entries in the 2.7 list <em>not</em> in the Python 3 list.</p>

<p>Generating the list is easy: <code>pip freeze</code> or <code>pip3.4 freeze</code>.</p>

<p>Searching for a package in the list is equally trivial <code>pip freeze | grep "wheel"</code> for example</p>

<p>However, if I want to search for intersections between the list, or in this instance <em>non</em>-intersections I would expect to use something like this <code>pip freeze | grep -n pip3.4 freeze</code></p>

<p>However it tells me that, obviously the parameter for grep <code>...is not a file or directory</code>. My shell scripting is rusty and I vaguely remember there should be a simple way of doing this other than piping both lists to files?</p>

<p>you can use also comm command as below</p>

<pre><code>comm -12 &lt;(pip freeze) &lt;(pip3.4 freeze)
</code></pre>

<p>to search for intersections;</p>

<pre><code>grep -f &lt;(pip freeze) &lt;(pip3.4 freeze)
</code></pre>

python bash list shell grep