#!/usr/bin/python3 from subprocess import getoutput # for Python 2 #from commands import getoutput output = getoutput("ps axu | grep vim | grep -v grep") print(output) print(len(output.split("\n")), "instances of vim are running")