Wait, wouldn&#x27;t you get the same result from running -U on the contents of the requirements file (after stripping the == out)? i.e.<p><pre><code>    sed &#x27;s&#x2F;==.*&#x2F;&#x2F;g&#x27; requirements.txt \
    | tr &#x27;\n&#x27; &#x27; &#x27; \
    | (read var; pip install -U $var) \
    &amp;&amp; pip freeze &gt; requirements.txt</code></pre>