from subprocess import getoutput #output = getoutput("who | grep tmux") output = getoutput("cat /usr/share/dict/american-english") if len(output) > 0: print("Yes, people are using tmux!") users = [l.split()[0] for l in output.split("\n")] for u in set(users): print(u)