4

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 not in the Python 3 list.

Generating the list is easy: pip freeze or pip3.4 freeze.

Searching for a package in the list is equally trivial pip freeze | grep "wheel" for example

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

However it tells me that, obviously the parameter for grep ...is not a file or directory. 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?

davidhood2
  • 1,367
  • 17
  • 47
  • 1
    `grep -vf <(pip freeze) <(pip3.4 freeze)` – 123 Oct 03 '16 at 09:36
  • 1
    @123 To list all python2 packages not in python3 list I think it should be `grep -vf <(pip3.4 freeze) <(pip freeze)` – SLePort Oct 03 '16 at 09:40
  • @Kenavoz yeah, tbh i didn't really read the question, just saw `I want to search for intersections between the list` – 123 Oct 03 '16 at 09:54

1 Answers1

1

you can use also comm command as below

comm -12 <(pip freeze) <(pip3.4 freeze)

to search for intersections;

grep -f <(pip freeze) <(pip3.4 freeze)
Mustafa DOGRU
  • 3,994
  • 1
  • 16
  • 24
  • 1
    This only works if the installed package versions match, and the second example treats a `.` in package names or versions as wildcard. Something like `grep -F -x -f <(pip2 freeze | sed 's/==.*//') <(pip3 freeze | sed 's/==.*//')` would ignore version numbers and match for full strings only. – mata Oct 03 '16 at 14:37